AgentKnowledge 是 Agno 中所有知识库类的基类。它提供了所有其他知识库类继承的通用功能和参数。
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
reader | Optional[Reader] | None | 用于读取文档的 Reader |
vector_db | Optional[VectorDb] | None | 用于存储知识库的 Vector db |
num_documents | int | 2 | 搜索时返回相关文档的数量 |
optimize_on | Optional[int] | 1000 | 用于优化向量数据库的文档数量 |
driver | str | "knowledge" | Assistant 知识的驱动程序 |
Property | Type | Description |
---|---|---|
document_lists | Iterator[List[Document]] | 知识库中文档列表的迭代器 |
async_document_lists | AsyncIterator[List[Document]] | 知识库中文档列表的异步迭代器 |
Method | Parameters | Return Type | Description |
---|---|---|---|
search | query: str, num_documents: Optional[int] = None, filters: Optional[Dict[str, Any]] = None | List[Document] | 返回与查询相关的文档列表 |
async_search | query: str, num_documents: Optional[int] = None, filters: Optional[Dict[str, Any]] = None | List[Document] | 异步返回与查询相关的文档列表 |
Method | Parameters | Return Type | Description |
---|---|---|---|
load | recreate: bool = False, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = None | None | 将知识库加载到向量数据库 |
aload | recreate: bool = False, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = None | None | 异步将知识库加载到向量数据库 |
load_documents | documents: List[Document], upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = None | None | 将文档加载到知识库 |
async_load_documents | documents: List[Document], upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = None | None | 异步将文档加载到知识库 |
load_document | document: Document, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = None | None | 将单个文档加载到知识库 |
async_load_document | document: Document, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = None | None | 异步将单个文档加载到知识库 |
load_dict | document: Dict[str, Any], upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = None | None | 将文档的字典表示加载到知识库 |
load_json | document: str, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = None | None | 将文档的 JSON 表示加载到知识库 |
load_text | text: str, upsert: bool = False, skip_existing: bool = True, filters: Optional[Dict[str, Any]] = None | None | 将文本加载到知识库 |
Method | Parameters | Return Type | Description |
---|---|---|---|
exists | None | bool | 如果知识库存在,则返回 True |
delete | None | bool | 清空知识库 |