import asyncio
from agno.agent import Agent
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase, PDFUrlReader
from agno.vectordb.qdrant import Qdrant
COLLECTION_NAME = "pdf-url-reader"
vector_db = Qdrant(collection=COLLECTION_NAME, url="http://localhost:6333")
# 使用 data/pdfs 目录中的 PDF 创建一个知识库
knowledge_base = PDFUrlKnowledgeBase(
urls=["https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"],
vector_db=vector_db,
reader=PDFUrlReader(chunk=True),
)
# 使用知识库创建一个 Agent
agent = Agent(
knowledge=knowledge_base,
search_knowledge=True,
)
if __name__ == "__main__":
# 首次运行时注释掉
asyncio.run(knowledge_base.aload(recreate=False))
# 创建并使用 Agent
asyncio.run(agent.aprint_response("How to make Thai curry?", markdown=True))