forked from openai/chatgpt-retrieval-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
10,399 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Ignore files that are already ignored by git | ||
.gitignore | ||
|
||
scripts/ | ||
tests/ | ||
examples/ | ||
*.md | ||
*.pyc | ||
.dockerignore | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# .vscode files | ||
.vscode/* | ||
|
||
# Pycharm | ||
.idea/ | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
myvenv/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# macOS .DS_Store files | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"schema_version": "v1", | ||
"name_for_model": "retrieval", | ||
"name_for_human": "Retrieval Plugin", | ||
"description_for_model": "Plugin for searching through the user's documents (such as files, emails, and more) to find answers to questions and retrieve relevant information. Use it whenever a user asks something that might be found in their personal information.", | ||
"description_for_human": "Search through your documents", | ||
"auth": { | ||
"type": "user_http", | ||
"authorization_type": "bearer" | ||
}, | ||
"api": { | ||
"type": "openapi", | ||
"url": "https://your-app-url.com/.well-known/openapi.yaml", | ||
"has_user_authentication": false | ||
}, | ||
"logo_url": "https://your-app-url.com/.well-known/logo.png", | ||
"contact_email": "hello@contact.com", | ||
"legal_info_url": "hello@legal.com" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
openapi: 3.0.2 | ||
info: | ||
title: Retrieval Plugin API | ||
description: A retrieval API for querying and filtering documents based on natural language queries and metadata | ||
version: 1.0.0 | ||
servers: | ||
- url: https://your-app-url.com | ||
paths: | ||
/query: | ||
post: | ||
summary: Query | ||
description: This endpoint accepts 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. If you receive a ResponseTooLargeError, try splitting up the queries into multiple calls to this endpoint. | ||
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: | ||
DocumentChunkMetadata: | ||
title: DocumentChunkMetadata | ||
type: object | ||
properties: | ||
source: | ||
$ref: "#/components/schemas/Source" | ||
source_id: | ||
title: Source Id | ||
type: string | ||
url: | ||
title: Url | ||
type: string | ||
created_at: | ||
title: Created At | ||
type: string | ||
author: | ||
title: Author | ||
type: string | ||
document_id: | ||
title: Document Id | ||
type: string | ||
DocumentChunkWithScore: | ||
title: DocumentChunkWithScore | ||
required: | ||
- text | ||
- metadata | ||
- score | ||
type: object | ||
properties: | ||
id: | ||
title: Id | ||
type: string | ||
text: | ||
title: Text | ||
type: string | ||
metadata: | ||
$ref: "#/components/schemas/DocumentChunkMetadata" | ||
embedding: | ||
title: Embedding | ||
type: array | ||
items: | ||
type: number | ||
score: | ||
title: Score | ||
type: number | ||
DocumentMetadataFilter: | ||
title: DocumentMetadataFilter | ||
type: object | ||
properties: | ||
document_id: | ||
title: Document Id | ||
type: string | ||
source: | ||
$ref: "#/components/schemas/Source" | ||
source_id: | ||
title: Source Id | ||
type: string | ||
author: | ||
title: Author | ||
type: string | ||
start_date: | ||
title: Start Date | ||
type: string | ||
end_date: | ||
title: End Date | ||
type: string | ||
HTTPValidationError: | ||
title: HTTPValidationError | ||
type: object | ||
properties: | ||
detail: | ||
title: Detail | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/ValidationError" | ||
Query: | ||
title: Query | ||
required: | ||
- query | ||
type: object | ||
properties: | ||
query: | ||
title: Query | ||
type: string | ||
filter: | ||
$ref: "#/components/schemas/DocumentMetadataFilter" | ||
top_k: | ||
title: Top K | ||
type: integer | ||
default: 3 | ||
QueryRequest: | ||
title: QueryRequest | ||
required: | ||
- queries | ||
type: object | ||
properties: | ||
queries: | ||
title: Queries | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/Query" | ||
QueryResponse: | ||
title: QueryResponse | ||
required: | ||
- results | ||
type: object | ||
properties: | ||
results: | ||
title: Results | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/QueryResult" | ||
QueryResult: | ||
title: QueryResult | ||
required: | ||
- query | ||
- results | ||
type: object | ||
properties: | ||
query: | ||
title: Query | ||
type: string | ||
results: | ||
title: Results | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/DocumentChunkWithScore" | ||
Source: | ||
title: Source | ||
enum: | ||
- file | ||
- chat | ||
type: string | ||
description: An enumeration. | ||
ValidationError: | ||
title: ValidationError | ||
required: | ||
- loc | ||
- msg | ||
- type | ||
type: object | ||
properties: | ||
loc: | ||
title: Location | ||
type: array | ||
items: | ||
anyOf: | ||
- type: string | ||
- type: integer | ||
msg: | ||
title: Message | ||
type: string | ||
type: | ||
title: Error Type | ||
type: string | ||
securitySchemes: | ||
HTTPBearer: | ||
type: http | ||
scheme: bearer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
FROM python:3.10 as requirements-stage | ||
|
||
WORKDIR /tmp | ||
|
||
RUN pip install poetry | ||
|
||
COPY ./pyproject.toml ./poetry.lock* /tmp/ | ||
|
||
|
||
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes | ||
|
||
FROM python:3.10 | ||
|
||
WORKDIR /code | ||
|
||
COPY --from=requirements-stage /tmp/requirements.txt /code/requirements.txt | ||
|
||
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | ||
|
||
COPY . /code/ | ||
|
||
# Heroku uses PORT, Azure App Services uses WEBSITES_PORT, Fly.io uses 8080 by default | ||
CMD ["sh", "-c", "uvicorn server.main:app --host 0.0.0.0 --port ${PORT:-${WEBSITES_PORT:-8080}}"] |
Oops, something went wrong.