diff --git a/ai/knowledge_base.py b/ai/knowledge_base.py index 7cbec91..742b885 100644 --- a/ai/knowledge_base.py +++ b/ai/knowledge_base.py @@ -4,21 +4,19 @@ from phi.knowledge.website import WebsiteKnowledgeBase from phi.vectordb.pgvector import PgVector2 +from ai.settings import ai_settings from db.session import db_url pdf_knowledge_base = CombinedKnowledgeBase( sources=[ - PDFUrlKnowledgeBase( - urls=["https://www.family-action.org.uk/content/uploads/2019/07/meals-more-recipes.pdf"] - ), + PDFUrlKnowledgeBase(urls=["https://phi-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"]), PDFKnowledgeBase(path="data/pdfs"), ], - # Store this knowledge base in ai.pdf_documents vector_db=PgVector2( - schema="ai", db_url=db_url, + # Store the embeddings in ai.pdf_documents collection="pdf_documents", - embedder=OpenAIEmbedder(model="text-embedding-3-small"), + embedder=OpenAIEmbedder(model=ai_settings.embedding_model), ), # 2 references are added to the prompt num_documents=2, @@ -29,12 +27,11 @@ # urls=["https://docs.phidata.com/introduction"], # Number of links to follow from the seed URLs max_links=15, - # Store this knowledge base in ai.website_documents vector_db=PgVector2( - schema="ai", db_url=db_url, + # Store the embeddings in ai.website_documents collection="website_documents", - embedder=OpenAIEmbedder(model="text-embedding-3-small"), + embedder=OpenAIEmbedder(model=ai_settings.embedding_model), ), # 3 references are added to the prompt num_documents=3, diff --git a/ai/settings.py b/ai/settings.py index 39242d2..82f9045 100644 --- a/ai/settings.py +++ b/ai/settings.py @@ -10,7 +10,7 @@ class AISettings(BaseSettings): gpt_4: str = "gpt-4-1106-preview" gpt_4_vision: str = "gpt-4-vision-preview" gpt_3_5: str = "gpt-3.5-turbo-1106" - embedding_model: str = "text-embedding-ada-002" + embedding_model: str = "text-embedding-3-small" default_max_tokens: int = 1024 default_temperature: float = 0 diff --git a/ai/storage.py b/ai/storage.py index d02c8ee..69fb8c5 100644 --- a/ai/storage.py +++ b/ai/storage.py @@ -3,19 +3,16 @@ from db.session import db_url pdf_assistant_storage = PgAssistantStorage( - schema="ai", db_url=db_url, table_name="pdf_assistant", ) image_assistant_storage = PgAssistantStorage( - schema="ai", db_url=db_url, table_name="image_assistant", ) website_assistant_storage = PgAssistantStorage( - schema="ai", db_url=db_url, table_name="website_assistant", ) diff --git a/pyproject.toml b/pyproject.toml index 763a8d5..2a1eee9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ # Linting and Formatting "ruff", # phidata - "phidata==2.3.19", + "phidata==2.3.25", ] [build-system] diff --git a/requirements.txt b/requirements.txt index be9c9cc..45154cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# ./scripts/upgrade.sh all +# ./scripts/upgrade.sh # alembic==1.13.1 altair==5.2.0 @@ -42,7 +42,7 @@ openai==1.11.0 packaging==23.2 pandas==2.2.0 pgvector==0.2.4 -phidata==2.3.19 +phidata==2.3.25 pillow==10.2.0 protobuf==4.25.2 psycopg[binary]==3.1.17 diff --git a/workspace/settings.py b/workspace/settings.py index 85f3994..2bd06e7 100644 --- a/workspace/settings.py +++ b/workspace/settings.py @@ -15,14 +15,14 @@ dev_env="dev", # -*- Dev Apps dev_app_enabled=True, - dev_api_enabled=True, + # dev_api_enabled=True, dev_db_enabled=True, # dev_jupyter_enabled=True, # -*- Production settings prd_env="prd", # -*- Production Apps prd_app_enabled=True, - prd_api_enabled=True, + # prd_api_enabled=True, prd_db_enabled=True, # -*- AWS settings # Region for AWS resources