Skip to content

Commit

Permalink
s3-knowledge-cookbooks-phi-2020
Browse files Browse the repository at this point in the history
  • Loading branch information
ysolanky committed Nov 20, 2024
1 parent aa4ecaf commit e08c22d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cookbook/knowledge/s3_pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from phi.agent import Agent
from phi.knowledge.s3.pdf import S3PDFKnowledgeBase
from phi.vectordb.pgvector import PgVector

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

knowledge_base = S3PDFKnowledgeBase(
bucket_name="phi-public",
key="recipes/ThaiRecipes.pdf",
vector_db=PgVector(table_name="recipes", db_url=db_url),
)
knowledge_base.load(recreate=False) # Comment out after first run

agent = Agent(knowledge=knowledge_base, search_knowledge=True)
agent.print_response("How to make Thai curry?", markdown=True)
15 changes: 15 additions & 0 deletions cookbook/knowledge/s3_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from phi.agent import Agent
from phi.knowledge.s3.text import S3TextKnowledgeBase
from phi.vectordb.pgvector import PgVector

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

knowledge_base = S3TextKnowledgeBase(
bucket_name="phi-public",
key="recipes/recipes.docx",
vector_db=PgVector(table_name="recipes", db_url=db_url),
)
knowledge_base.load(recreate=False) # Comment out after first run

agent = Agent(knowledge=knowledge_base, search_knowledge=True)
agent.print_response("How to make Hummus?", markdown=True)

0 comments on commit e08c22d

Please sign in to comment.