Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
v2.3.14
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Feb 4, 2024
1 parent 9894fc6 commit 8b05193
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 31 deletions.
38 changes: 9 additions & 29 deletions ai/knowledge_base.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@
from phi.embedder.openai import OpenAIEmbedder
from phi.knowledge.combined import CombinedKnowledgeBase
from phi.knowledge.pdf import PDFUrlKnowledgeBase, PDFKnowledgeBase
from phi.vectordb.pgvector import PgVector
from phi.vectordb.pgvector import PgVector2

from db.session import db_url

url_pdf_knowledge_base = PDFUrlKnowledgeBase(
urls=["https://www.family-action.org.uk/content/uploads/2019/07/meals-more-recipes.pdf"],
# Store this knowledge base in ai.url_pdf_documents
vector_db=PgVector(
schema="ai",
db_url=db_url,
collection="url_pdf_documents",
),
# 2 references are added to the prompt
num_documents=2,
)

local_pdf_knowledge_base = PDFKnowledgeBase(
path="data/pdfs",
# Store this knowledge base in ai.local_pdf_documents
vector_db=PgVector(
schema="ai",
db_url=db_url,
collection="local_pdf_documents",
),
# 3 references are added to the prompt
num_documents=3,
)

pdf_knowledge_base = CombinedKnowledgeBase(
sources=[
url_pdf_knowledge_base,
local_pdf_knowledge_base,
PDFUrlKnowledgeBase(
urls=["https://www.family-action.org.uk/content/uploads/2019/07/meals-more-recipes.pdf"]
),
PDFKnowledgeBase(path="data/pdfs"),
],
# Store this knowledge base in ai.pdf_documents
vector_db=PgVector(
vector_db=PgVector2(
schema="ai",
db_url=db_url,
collection="pdf_documents",
embedder=OpenAIEmbedder(model="text-embedding-3-small"),
),
# 2 references are added to the prompt
num_documents=2,
)
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies = [
# Linting and Formatting
"ruff",
# phidata
"phidata==2.3.13",
"phidata==2.3.14",
]

[build-system]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ numpy==1.26.3
openai==1.11.0
packaging==23.2
pgvector==0.2.4
phidata==2.3.13
phidata==2.3.14
pluggy==1.4.0
psycopg[binary]==3.1.17
psycopg-binary==3.1.17
Expand Down

0 comments on commit 8b05193

Please sign in to comment.