Search Dify Knowledge Base (Dataset) to get accurate context for RAG-enhanced answers.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install dify-kb-search或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install dify-kb-search⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/dify-kb-search/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: dify-kb-search description: Search Dify Knowledge Base (Dataset) to get accurate context for RAG-enhanced answers. metadata: openclaw: requires: env: - DIFY_API_KEY - DIFY_BASE_URL install: - id: python kind: node package: python3 bins: - python3 - id: requests kind: node package: requests bins: [] label: Install Python requests library commandDispatch: tool commandTool: exec commandArgMode: json ---
🔍 Search your Dify Knowledge Base to get accurate, contextual answers
This skill enables AI agents to query Dify datasets for RAG (Retrieval-Augmented Generation) context retrieval. Perfect for knowledge base Q&A, documentation search, and contextual AI responses.
Set up in openclaw.json:
{
"env": {
"vars": {
"DIFY_API_KEY": "${DIFY_API_KEY}",
"DIFY_BASE_URL": "https://dify.example.com/v1"
}
}
}
Environment Variables:
| Variable | Required | Default | Description | |----------|----------|---------|-------------| | DIFY_API_KEY | ✅ Yes | - | Your Dify API Key (from Settings → API) | | DIFY_BASE_URL | ❌ No | http://localhost/v1 | Your Dify instance base URL |
pip3 install requests
Lists all available knowledge bases (datasets) in your Dify instance.
Invocation: dify_list tool
Example Response:
{
"status": "success",
"count": 2,
"datasets": [
{
"id": "dataset-abc123",
"name": "Product Documentation",
"doc_count": 42,
"description": "All product guides and tutorials"
},
{
"id": "dataset-xyz789",
"name": "API Reference",
"doc_count": 156,
"description": "REST API documentation"
}
]
}
Usage:
{}
Searches a Dify Dataset for relevant context chunks.
Invocation: dify_search tool (mapped to python3 scripts/search.py)
Parameters:
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | query | string | ✅ Yes | - | Search query or question | | dataset_id | string | ❌ No | Auto-discover | Specific dataset ID to search | | top_k | integer | ❌ No | 3 | Number of results to return | | search_method | string | ❌ No | hybrid_search | Search strategy | | reranking_enable | boolean | ❌ No | false | Enable reranking for better results |
Search Methods:
hybrid_search - Combine semantic + keyword search (recommended)semantic_search - Meaning-based similarity searchkeyword_search - Exact keyword matchingExample Usage:
{
"query": "How do I configure OpenClaw?",
"top_k": 5
}
{
"query": "API authentication methods",
"dataset_id": "dataset-xyz789",
"search_method": "semantic_search",
"reranking_enable": true
}
Example Response:
{
"status": "success",
"query": "How do I configure OpenClaw?",
"dataset_id": "dataset-abc123",
"count": 3,
"results": [
{
"content": "To configure OpenClaw, edit the openclaw.json file...",
"score": 0.8923,
"title": "Installation Guide",
"document_id": "doc-001"
},
{
"content": "OpenClaw supports environment variables via...",
"score": 0.8451,
"title": "Configuration Options",
"document_id": "doc-002"
}
]
}
[
{
"tool": "dify_list",
"parameters": {}
},
{
"tool": "dify_search",
"parameters": {
"query": "What are the system requirements?",
"top_k": 5,
"search_method": "hybrid_search"
}
}
]
| Error | Solution | |-------|----------| | Missing DIFY_API_KEY | Set DIFY_API_KEY in environment variables | | Connection refused | Check DIFY_BASE_URL is correct and accessible | | No datasets found | Verify dataset exists in your Dify workspace | | API request failed | Check network connectivity and API key permissions |
Run manually to see detailed errors:
DIFY_API_KEY=your-key python3 scripts/search.py <<< '{"query":"test"}'
# Example: Use search results in AI response
results = dify_search(query, top_k=5)
context = "\n".join([r["content"] for r in results["results"]])
final_prompt = f"Answer based on context:\n\n{context}\n\nQuestion: {query}"
For searching across multiple datasets, loop through them:
{
"query": "Find information about authentication",
"dataset_id": "dataset-api-docs"
}
Then query another dataset separately.
.env filesThis skill uses the Dify Dataset API:
GET /v1/datasetsPOST /v1/datasets/{id}/retrieveFor API documentation, see: https://docs.dify.ai/reference/api-reference
v1.1.0 (2026-02-08):
v1.0.0 (2026-02-06):
安装 Dify Knowledge Base Search 后,可以对 AI 说这些话来触发它
Help me get started with Dify Knowledge Base Search
Explains what Dify Knowledge Base Search does, walks through the setup, and runs a quick demo based on your current project
Use Dify Knowledge Base Search to search Dify Knowledge Base (Dataset) to get accurate context for RA...
Invokes Dify Knowledge Base Search with the right parameters and returns the result directly in the conversation
What can I do with Dify Knowledge Base Search in my data & analytics workflow?
Lists the top use cases for Dify Knowledge Base Search, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/dify-kb-search/ 目录(个人级,所有项目可用),或 .claude/skills/dify-kb-search/(项目级)。重启 AI 客户端后,用 /dify-kb-search 主动调用,或让 AI 根据上下文自动发现并使用。
Dify Knowledge Base Search 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Dify Knowledge Base Search 可免费安装使用。请查阅仓库了解许可证信息。
Search Dify Knowledge Base (Dataset) to get accurate context for RAG-enhanced answers.
Dify Knowledge Base Search 属于「Data & Analytics」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my data & analytics tasks using Dify Knowledge Base Search
Identifies repetitive steps in your workflow and sets up Dify Knowledge Base Search to handle them automatically