用法
我们在此示例中使用本地 PgVector 数据库。请确保它正在运行
knowledge_base 与 Agent 一起使用:
参数
DocumentKnowledgeBase 是 AgentKnowledge 类的子类,可以访问相同的参数。
开发者资源
- 查看 同步加载 Cookbook
- 查看 异步加载 Cookbook
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
了解如何在知识库中使用本地文档。
pip install textract
from agno.knowledge.document import DocumentKnowledgeBase
from agno.vectordb.pgvector import PgVector
knowledge_base = DocumentKnowledgeBase(
path="data/docs",
# 表名:ai.documents
vector_db=PgVector(
table_name="documents",
db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
),
)
knowledge_base 与 Agent 一起使用:
from agno.agent import Agent
from knowledge_base import knowledge_base
agent = Agent(
knowledge=knowledge_base,
search_knowledge=True,
)
agent.knowledge.load(recreate=False)
agent.print_response("就知识库中的某个问题问我")
| 参数 | 类型 | 默认 | 描述 |
|---|---|---|---|
documents | List[Document] | - | 要用作知识库的 Document 对象列表 |
DocumentKnowledgeBase 是 AgentKnowledge 类的子类,可以访问相同的参数。