import asyncio
from pathlib import Path
from agno.agent import Agent
from agno.knowledge.csv import CSVKnowledgeBase
from agno.vectordb.qdrant import Qdrant
COLLECTION_NAME = "csv-reader"
vector_db = Qdrant(collection=COLLECTION_NAME, url="http://localhost:6333")
knowledge_base = CSVKnowledgeBase(
path=Path("data/csv"),
vector_db=vector_db,
num_documents=5, # 搜索时返回的文档数量
)
# 使用 knowledge_base 初始化 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("What is the csv file about", markdown=True))