diff --git a/install.py b/install.py deleted file mode 100644 index 8abef40..0000000 --- a/install.py +++ /dev/null @@ -1,43 +0,0 @@ -import asyncio -import asyncpg -import os -from config import Config - -conn = None - -class Install: - dbi: asyncpg.Connection - - async def run(self): - db_config = Config.get("database") - self.dbi = await asyncpg.connect(db_config) - args = os.sys.argv - if "--force" in args: - await self.drop_table() - - await self.create_table() - - async def drop_table(self): - await self.dbi.execute("DROP TABLE IF EXISTS embedding_search_title_index;") - print("Table dropped") - - async def create_table(self): - embedding_vector_size = Config.get("chatcomplete.embedding_vector_size", 512, int) - - await self.dbi.execute(""" - CREATE TABLE embedding_search_title_index ( - id SERIAL PRIMARY KEY, - sha1 VARCHAR(40) NOT NULL UNIQUE, - title TEXT NOT NULL, - rev_id INT8 NOT NULL, - embedding VECTOR(%d) NOT NULL - ); - """ % (embedding_vector_size)) - await self.dbi.execute("CREATE INDEX embedding_search_title_index_embedding_idx ON embedding_search_title_index USING ivfflat (embedding vector_cosine_ops);") - print("Table created") - -if __name__ == "__main__": - install = Install() - - loop = asyncio.get_event_loop() - loop.run_until_complete(install.run()) \ No newline at end of file diff --git a/service/chat_complete.py b/service/chat_complete.py index 056c7cb..af60196 100644 --- a/service/chat_complete.py +++ b/service/chat_complete.py @@ -15,7 +15,6 @@ from config import Config import utils.config, utils.web from aiohttp import web -from api.model.embedding_search.title_collection import TitleCollectionModel from sqlalchemy.orm.attributes import flag_modified from service.database import DatabaseService diff --git a/service/openai_api.py b/service/openai_api.py index ebd9b4a..d81320e 100644 --- a/service/openai_api.py +++ b/service/openai_api.py @@ -10,6 +10,9 @@ from aiohttp_sse_client2 import client as sse_client from service.tiktoken import TikTokenService +AZURE_CHATCOMPLETE_API_VERSION = "2023-07-01-preview" +AZURE_EMBEDDING_API_VERSION = "2023-05-15" + class ChatCompleteMessageLog(TypedDict): role: str content: str @@ -89,7 +92,7 @@ class OpenAIApi: } if self.api_type == "azure": - params["api-version"] = "2023-05-15" + params["api-version"] = AZURE_EMBEDDING_API_VERSION else: post_data["model"] = "text-embedding-ada-002" @@ -190,7 +193,7 @@ class OpenAIApi: } if self.api_type == "azure": - params["api-version"] = "2023-05-15" + params["api-version"] = AZURE_CHATCOMPLETE_API_VERSION else: post_data["model"] = "gpt-3.5-turbo" @@ -248,7 +251,7 @@ class OpenAIApi: } if self.api_type == "azure": - params["api-version"] = "2023-05-15" + params["api-version"] = AZURE_CHATCOMPLETE_API_VERSION else: post_data["model"] = "gpt-3.5-turbo"