> ## Documentation Index
> Fetch the complete documentation index at: https://docs.veadk.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# 知识库检索

## 功能说明

对应工具标识 `load_knowledgebase`。

系统工具由 VeADK 根据智能体配置**自动挂载**，无需手动加入 `tools` 列表。为智能体传入 `knowledgebase` 后，框架自动挂载 `load_knowledgebase` 工具。智能体会根据用户问题自主决定何时查询知识库、用什么关键词检索，并把命中的知识作为上下文用于回答。

知识库的后端类型、初始化与数据写入，详见[知识库文档](/productions/veadk/archives/1.0.8/zh/components/knowledge)。

## 使用方法

```python lines theme={null}
from veadk import Agent, Runner
from veadk.knowledgebase import KnowledgeBase

# 构建知识库（后端类型与数据写入见知识库文档）
knowledgebase = KnowledgeBase(backend="local", index="company_faq")

agent = Agent(
    name="kb_agent",
    model_name="doubao-seed-2-1-pro-260628",
    instruction="回答用户问题时，在需要的地方检索知识库。",
    knowledgebase=knowledgebase,  # 传入后自动挂载 load_knowledgebase
)

runner = Runner(agent=agent)
```

## 额外说明

<Note>
  系统工具由框架自动管理：只需提供 `knowledgebase`，无需把 `load_knowledgebase` 显式加入 `tools` 列表。智能体会根据指令与用户输入自主决定何时调用它。
</Note>
