# Knowledge Manager Agent 知识库管理 Agent,负责知识库的查询、维护和更新。 ## 功能 ### 1. 查询模式(Librarian) 帮助其他 Agent 了解知识库中已有的内容。 **使用示例**: ```python # 在调研前查询已有信息 result = agent("knowledge_manager", "查询知识库中关于 ControlNet 的所有信息") ``` **输出**: - 已有工具列表 - 已有资源列表 - 已有知识列表 - 补充建议 ### 2. 保存模式(Saver) 接收调研结果,智能去重并保存到知识库。 **使用示例**: ```python # 调研完成后保存结果 data = { "tools": [...], "resources": [...], "knowledge": [...] } result = agent("knowledge_manager", f"保存以下调研结果:{json.dumps(data, ensure_ascii=False)}") ``` ## 数据格式 ### 工具(tools) ```json { "name": "ControlNet", "slug": "controlnet", "category": "plugin", "version": "1.1", "description": "SD 姿态控制插件", "tutorial": "使用方法...", "source_url": "https://..." } ``` ### 资源(resources) ```json { "title": "ControlNet 官方文档", "body": "文档内容...", "content_type": "documentation", "source_url": "https://...", "metadata": {} } ``` ### 知识(knowledge) ```json { "task": "在生成人物图像时,需要控制姿态", "content": "使用 ControlNet 插件...", "types": ["tool"], "tags": {"tool": "controlnet"}, "score": 4 } ``` ## 环境配置 需要设置以下环境变量: ```bash export DATABASE_URL="postgresql://user:pass@localhost:5432/knowhub" export KNOWHUB_API="http://localhost:8000" ``` ## 作为子 Agent 使用 在 presets.json 中注册: ```json { "knowledge_manager": { "prompt_file": "knowhub/agents/knowledge_manager.prompt", "model": "qwen3.5-plus", "temperature": 0.2 } } ``` 在主 Agent 中调用: ```python # 通过 agent 工具调用 result = agent("knowledge_manager", "查询 ControlNet") ```