From cc6cc1730ba26a26628db4c27941e2991512cdae Mon Sep 17 00:00:00 2001 From: leoguillaume Date: Wed, 16 Oct 2024 12:05:09 +0200 Subject: [PATCH] fix: minor fixes --- app/endpoints/files.py | 4 ++-- app/helpers/_modelclients.py | 2 +- docs/tutorials/chat_completions.ipynb | 12 +++++++++++- docs/tutorials/import_knowledge_database.ipynb | 2 +- ui/pages/documents.py | 4 +++- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/endpoints/files.py b/app/endpoints/files.py index e24224d..dce70b4 100644 --- a/app/endpoints/files.py +++ b/app/endpoints/files.py @@ -17,8 +17,8 @@ async def upload_file(file: UploadFile = File(...), request: FilesRequest = Body Supported files types: - pdf: Portable Document Format file. - json: JavaScript Object Notation file. - For JSON, file structure like a list of documents: [{"text": "hello world", "metadata": {"title": "my document"}}, ...]} or [{"text": "hello world"}, ...]} - Each document must have a "text" key and "metadata" key (optional) with dict type value. + For JSON, file structure like a list of documents: [{"text": "hello world", "title": "my document", "metadata": {"autor": "me"}}, ...]} or [{"text": "hello world", "title": "my document"}, ...]} + Each document must have a "text" and "title" keys and "metadata" key (optional) with dict type value. - html: Hypertext Markup Language file. Max file size is 10MB. diff --git a/app/helpers/_modelclients.py b/app/helpers/_modelclients.py index 5526f53..65dde2b 100644 --- a/app/helpers/_modelclients.py +++ b/app/helpers/_modelclients.py @@ -98,7 +98,7 @@ def create_embeddings(self, *args, **kwargs): class ModelClient(OpenAI): - DEFAULT_TIMEOUT = 10 + DEFAULT_TIMEOUT = 60 def __init__(self, type=Literal[EMBEDDINGS_MODEL_TYPE, LANGUAGE_MODEL_TYPE], *args, **kwargs): """ diff --git a/docs/tutorials/chat_completions.ipynb b/docs/tutorials/chat_completions.ipynb index 7e66b51..ebc144a 100644 --- a/docs/tutorials/chat_completions.ipynb +++ b/docs/tutorials/chat_completions.ipynb @@ -8,6 +8,16 @@ "# Chat completions" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "0df030ba", + "metadata": {}, + "outputs": [], + "source": [ + "%pip install -qU openai" + ] + }, { "cell_type": "code", "execution_count": 2, @@ -79,7 +89,7 @@ "for chunk in response:\n", " if chunk.choices[0].finish_reason is not None:\n", " break\n", - " print(chunk.choices[0].delta.content, end=\"\", flush=True)" + " print(chunk.choices[0].delta.content, end=\"\\n\", flush=True)" ] } ], diff --git a/docs/tutorials/import_knowledge_database.ipynb b/docs/tutorials/import_knowledge_database.ipynb index 8f28dd8..0934b2e 100644 --- a/docs/tutorials/import_knowledge_database.ipynb +++ b/docs/tutorials/import_knowledge_database.ipynb @@ -86,7 +86,7 @@ "source": [ "Le format du fichier doit être JSON, ici nous n'avons pas besoin de le convertir. En revanche, il est possible que le fichier ne respecte pas la structure définit dans la documentation de l'API.\n", "\n", - "De plus le fichier ne doit pas dépasser 5MB, il est donc nécessaire de le découper en plusieurs fichiers." + "De plus le fichier ne doit pas dépasser 10MB, il est donc nécessaire de le découper en plusieurs fichiers." ] }, { diff --git a/ui/pages/documents.py b/ui/pages/documents.py index d95446b..2450120 100644 --- a/ui/pages/documents.py +++ b/ui/pages/documents.py @@ -92,7 +92,9 @@ with col1: with st.expander("Upload a file", icon="📑"): collection = st.selectbox( - "Select a collection", [f"{collection["name"]} - {collection["id"]}" for collection in collections], key="upload_file_selectbox" + "Select a collection", + [f"{collection["name"]} - {collection["id"]}" for collection in collections if collection["type"] == PRIVATE_COLLECTION_TYPE], + key="upload_file_selectbox", ) collection_id = collection.split(" - ")[-1] file_to_upload = st.file_uploader("File", type=["pdf", "html", "json"])