Skip to content

Instantly share code, notes, and snippets.

@jamescalam
Created March 24, 2023 09:02
Show Gist options
  • Save jamescalam/709f83e4515975df832bf06c8a33ff26 to your computer and use it in GitHub Desktop.
Save jamescalam/709f83e4515975df832bf06c8a33ff26 to your computer and use it in GitHub Desktop.
openapi: 3.0.0
info:
title: Retrieval Plugin API
version: 1.0.0
description: This API lets you search through the LangChain Documentation.
servers:
- url: https://lobster-app-znw6z.ondigitalocean.app
paths:
/query:
post:
summary: Query
operationId: query_query_post
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/QueryRequest"
required: true
responses:
"200":
description: Successful Response
content:
application/json:
schema:
$ref: "#/components/schemas/QueryResponse"
"422":
description: Validation Error
content:
application/json:
schema:
$ref: "#/components/schemas/HTTPValidationError"
security:
- HTTPBearer: []
components:
schemas:
Document:
required:
- text
type: object
properties:
id:
type: string
text:
type: string
metadata:
$ref: "#/components/schemas/DocumentMetadata"
DocumentChunkMetadata:
type: object
properties:
source:
$ref: "#/components/schemas/Source"
source_id:
type: string
url:
type: string
created_at:
type: string
author:
type: string
document_id:
type: string
DocumentChunkWithScore:
required:
- document_id
- text
- score
type: object
properties:
id:
type: string
document_id:
type: string
text:
type: string
metadata:
$ref: "#/components/schemas/DocumentChunkMetadata"
embedding:
type: array
items:
type: number
score:
description: cosine similarity between the query and the document snippet. Higher scores are more similar.
type: number
DocumentMetadata:
type: object
properties:
source:
$ref: "#/components/schemas/Source"
source_id:
type: string
url:
type: string
created_at:
type: string
author:
type: string
DocumentMetadataFilter:
type: object
properties:
document_id:
type: string
source:
$ref: "#/components/schemas/Source"
source_id:
type: string
author:
type: string
start_date:
type: string
end_date:
type: string
HTTPValidationError:
type: object
properties:
detail:
type: array
items:
$ref: "#/components/schemas/ValidationError"
Query:
required:
- query
type: object
properties:
query:
type: string
filter:
$ref: "#/components/schemas/DocumentMetadataFilter"
top_k:
description: number of results to show
type: integer
default: 5
QueryRequest:
required:
- queries
type: object
properties:
queries:
type: array
description: This is an array of search query objects, each containing a natural language query string ("query") and an optional metadata filter ("filter"). Filters can help refine search results based on criteria such as document source or time period, but are not necessary in most cases. You can send multiple queries to compare information from different sources or break down complex questions into sub-questions.
items:
$ref: "#/components/schemas/Query"
QueryResponse:
required:
- results
type: object
properties:
results:
type: array
items:
$ref: "#/components/schemas/QueryResult"
QueryResult:
required:
- query
- results
type: object
properties:
query:
type: string
results:
type: array
items:
$ref: "#/components/schemas/DocumentChunkWithScore"
Source:
enum:
- email
- file
- chat
type: string
description: An enumeration.
ValidationError:
required:
- loc
- msg
- type
type: object
properties:
loc:
type: array
items:
anyOf:
- type: string
- type: integer
msg:
type: string
type:
type: string
securitySchemes:
HTTPBearer:
type: http
scheme: bearer
@Katlego-Chagane
Copy link

This works, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment