This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9894fc6
commit 8b05193
Showing
3 changed files
with
11 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters