From 1f4ffbeb3890b9f93a151cd80f046e5956f02e87 Mon Sep 17 00:00:00 2001 From: Bojan Rajh Date: Wed, 31 Jan 2024 16:55:52 +0100 Subject: [PATCH] feat: update deps, fix stats --- poetry.lock | 50 ++++++++++++++++++------------------------------ pyproject.toml | 4 ++-- web/answering.py | 9 +++++++-- 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/poetry.lock b/poetry.lock index ca20b23..ec91557 100644 --- a/poetry.lock +++ b/poetry.lock @@ -427,17 +427,6 @@ files = [ marshmallow = ">=3.18.0,<4.0.0" typing-inspect = ">=0.4.0,<1" -[[package]] -name = "distro" -version = "1.9.0" -description = "Distro - an OS platform information API" -optional = false -python-versions = ">=3.6" -files = [ - {file = "distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2"}, - {file = "distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed"}, -] - [[package]] name = "emoji" version = "2.10.1" @@ -502,18 +491,18 @@ files = [ [[package]] name = "fastapi" -version = "0.108.0" +version = "0.109.0" description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" optional = false python-versions = ">=3.8" files = [ - {file = "fastapi-0.108.0-py3-none-any.whl", hash = "sha256:8c7bc6d315da963ee4cdb605557827071a9a7f95aeb8fcdd3bde48cdc8764dd7"}, - {file = "fastapi-0.108.0.tar.gz", hash = "sha256:5056e504ac6395bf68493d71fcfc5352fdbd5fda6f88c21f6420d80d81163296"}, + {file = "fastapi-0.109.0-py3-none-any.whl", hash = "sha256:8c77515984cd8e8cfeb58364f8cc7a28f0692088475e2614f7bf03275eba9093"}, + {file = "fastapi-0.109.0.tar.gz", hash = "sha256:b978095b9ee01a5cf49b19f4bc1ac9b8ca83aa076e770ef8fd9af09a2b88d191"}, ] [package.dependencies] pydantic = ">=1.7.4,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0 || >2.0.0,<2.0.1 || >2.0.1,<2.1.0 || >2.1.0,<3.0.0" -starlette = ">=0.29.0,<0.33.0" +starlette = ">=0.35.0,<0.36.0" typing-extensions = ">=4.8.0" [package.extras] @@ -1784,26 +1773,25 @@ signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"] [[package]] name = "openai" -version = "1.10.0" -description = "The official Python library for the openai API" +version = "0.28.1" +description = "Python client library for the OpenAI API" optional = false python-versions = ">=3.7.1" files = [ - {file = "openai-1.10.0-py3-none-any.whl", hash = "sha256:aa69e97d0223ace9835fbf9c997abe9ee95318f684fd2de6d02c870700c71ebc"}, - {file = "openai-1.10.0.tar.gz", hash = "sha256:208886cb501b930dc63f48d51db9c15e5380380f80516d07332adad67c9f1053"}, + {file = "openai-0.28.1-py3-none-any.whl", hash = "sha256:d18690f9e3d31eedb66b57b88c2165d760b24ea0a01f150dd3f068155088ce68"}, + {file = "openai-0.28.1.tar.gz", hash = "sha256:4be1dad329a65b4ce1a660fe6d5431b438f429b5855c883435f0f7fcb6d2dcc8"}, ] [package.dependencies] -anyio = ">=3.5.0,<5" -distro = ">=1.7.0,<2" -httpx = ">=0.23.0,<1" -pydantic = ">=1.9.0,<3" -sniffio = "*" -tqdm = ">4" -typing-extensions = ">=4.7,<5" +aiohttp = "*" +requests = ">=2.20" +tqdm = "*" [package.extras] -datalib = ["numpy (>=1)", "pandas (>=1.2.3)", "pandas-stubs (>=1.1.0.11)"] +datalib = ["numpy", "openpyxl (>=3.0.7)", "pandas (>=1.2.3)", "pandas-stubs (>=1.1.0.11)"] +dev = ["black (>=21.6b0,<22.0)", "pytest (==6.*)", "pytest-asyncio", "pytest-mock"] +embeddings = ["matplotlib", "numpy", "openpyxl (>=3.0.7)", "pandas (>=1.2.3)", "pandas-stubs (>=1.1.0.11)", "plotly", "scikit-learn (>=1.0.2)", "scipy", "tenacity (>=8.0.1)"] +wandb = ["numpy", "openpyxl (>=3.0.7)", "pandas (>=1.2.3)", "pandas-stubs (>=1.1.0.11)", "wandb"] [[package]] name = "opt-einsum" @@ -2814,13 +2802,13 @@ sqlcipher = ["sqlcipher3_binary"] [[package]] name = "starlette" -version = "0.32.0.post1" +version = "0.35.1" description = "The little ASGI library that shines." optional = false python-versions = ">=3.8" files = [ - {file = "starlette-0.32.0.post1-py3-none-any.whl", hash = "sha256:cd0cb10ddb49313f609cedfac62c8c12e56c7314b66d89bb077ba228bada1b09"}, - {file = "starlette-0.32.0.post1.tar.gz", hash = "sha256:e54e2b7e2fb06dff9eac40133583f10dfa05913f5a85bf26f427c7a40a9a3d02"}, + {file = "starlette-0.35.1-py3-none-any.whl", hash = "sha256:50bbbda9baa098e361f398fda0928062abbaf1f54f4fadcbe17c092a01eb9a25"}, + {file = "starlette-0.35.1.tar.gz", hash = "sha256:3e2639dac3520e4f58734ed22553f950d3f3cb1001cd2eaac4d57e8cdc5f66bc"}, ] [package.dependencies] @@ -3806,4 +3794,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.12" -content-hash = "af9c584693f906e461c94c064c9650dba1e3b58b4745ba00f171eca624bf1fc5" +content-hash = "0c71ccafa7da1a6c5fef840df957237902e42eed0f8a26b5819649d0e9b9625a" diff --git a/pyproject.toml b/pyproject.toml index 0e1cb4b..ad14419 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,9 +12,9 @@ langchain = "^0.0.354" faiss-cpu = "^1.7.4" unstructured = "^0.11.8" libmagic = "^1.0" -openai = "^1.6.1" +openai = "^0.28.1" tiktoken = "^0.5.2" -fastapi = "^0.108.0" +fastapi = "^0.109.0" pydantic = "^2.5.3" pydantic-settings = "^2.1.0" uvicorn = "^0.25.0" diff --git a/web/answering.py b/web/answering.py index c712e85..d732006 100644 --- a/web/answering.py +++ b/web/answering.py @@ -83,8 +83,13 @@ async def generate_answer(question: str, collection): # track event await send_event('all', 'qa', {**{"question": question, "collection": collection, "instances": instances}, **cb.__dict__}) - output['stats'] = cb - + output['stats'] = { + 'total_cost': cb.total_cost, + 'total_tokens': cb.total_tokens, + 'prompt_tokens': cb.prompt_tokens, + 'completion_tokens': cb.completion_tokens, + 'successful_requests': cb.successful_requests, + } return output