D
dify-knowledge-base-search
About dify-knowledge-base-search
dify-knowledge-base-search is a skill for retrieving dataset content through Dify. It guides users through request setup, response interpretation, and troubleshooting for knowledge retrieval workflows.
Key features
- 01Call the Dify dataset retrieval endpoint
- 02Set a query and optional top_k
- 03Interpret records in the response
- 04Troubleshoot authentication and route issues
Use cases
- 01Search a Dify dataset with a query
- 02Increase top_k when more records are needed
- 03Resolve API authentication or routing errors
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ tiangong-ai/ agent-skills --skill dify-knowledge-base-searchAfter installing, type/dify-knowledge-base-searchin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlassets/example-request.jsonreferences/env.mdrequest-response.mdtesting.mdDetails
From the project READMEDify Knowledge Base Search
Prepare required inputs
- Provide
dataas JSON containingqueryand optionalretrieval_model.top_k. - Read these env vars:
DIFY_API_BASE_URL: base API URL and include/v1(example:https://api.dify.ai/v1).DIFY_DATASET_ID: target dataset ID.DIFY_API_KEY: send asAuthorization: Bearer <DIFY_API_KEY>.
Send request
- Endpoint:
${DIFY_API_BASE_URL}/datasets/${DIFY_DATASET_ID}/retrieve - Headers:
Content-Type: application/jsonAuthorization: Bearer <DIFY_API_KEY>
- Use
assets/example-request.jsonas the payload template.
curl -sS --location --request POST "$DIFY_API_BASE_URL/datasets/$DIFY_DATASET_ID/retrieve" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DIFY_API_KEY" \
--data @assets/example-request.json
Interpret response
- Request shape:
{ "query": string, "retrieval_model"?: { "top_k": number } } - Success shape: 200 with
{ query, records: [...] } - If
recordsis empty, increaseretrieval_model.top_kmoderately and retry.
Troubleshoot quickly
- If auth fails, verify
DIFY_API_KEYandAuthorizationheader format. - If route fails, verify
DIFY_API_BASE_URLincludes/v1. - If results are low quality, refine
queryand tunetop_k.
References
references/env.mdreferences/request-response.mdreferences/testing.md
Assets
assets/example-request.json
Comments
Markdown supported