How can external LLM use the dify knowledge base through agents #8643

Closed
opened 2026-02-21 18:26:49 -05:00 by yindo · 6 comments
Owner

Originally created by @AuTingU on GitHub (Feb 26, 2025).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Provide a description of requested docs changes

How can external LLM use the dify knowledge base through agents

Originally created by @AuTingU on GitHub (Feb 26, 2025). ### Self Checks - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Provide a description of requested docs changes How can external LLM use the dify knowledge base through agents
yindo added the 📚 documentation🙋‍♂️ question🌚 invalid labels 2026-02-21 18:26:49 -05:00
yindo closed this issue 2026-02-21 18:26:49 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 26, 2025):

Hello @AuTingU! I'm here to help you with bug fixes, answer questions, and support you as a contributor. Let's work together to solve any issues you encounter.

To enable an external LLM to use the DIY knowledge base through agents in Dify, you need to follow these steps:

  1. Connect to an External Knowledge Base: Navigate to the "Knowledge" page and select "Connect to an External Knowledge Base" to access the configuration page.

  2. Configure Parameters:

    • Knowledge Base Name & Description: Provide a name and description.
    • External Knowledge API: Choose the API for the external knowledge base.
    • External Knowledge ID: Specify the ID for the external knowledge base.
    • Retrieval Setting:
      • Top K: Set the number of relevant content chunks to retrieve (default is 3).
      • Score Threshold: Set the similarity threshold for filtering text chunks (default is 0.5).
  3. Set Up Endpoint: Configure an endpoint for the retrieval API:

    POST <your-endpoint>/retrieval
    
  4. Authorization: Use an API-Key in the Authorization HTTP Header:

    Authorization: Bearer {API_KEY}
    
  5. Request Body: Send a JSON request with:

    • knowledge_id: Unique ID of your knowledge base.
    • query: User's query.
    • retrieval_setting: Object with top_k and score_threshold.
  6. Request Example:

    POST <your-endpoint>/retrieval HTTP/1.1
    Content-Type: application/json
    Authorization: Bearer your-api-key
    
    {
        "knowledge_id": "your-knowledge-id",
        "query": "your question",
        "retrieval_setting": {
            "top_k": 2,
            "score_threshold": 0.5
        }
    }
    

These steps will allow the external LLM to interact with the DIY knowledge base through agents [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Feb 26, 2025): <!-- Greeting --> Hello @AuTingU! I'm here to help you with bug fixes, answer questions, and support you as a contributor. Let's work together to solve any issues you encounter. <!-- Answer --> To enable an external LLM to use the DIY knowledge base through agents in Dify, you need to follow these steps: 1. **Connect to an External Knowledge Base**: Navigate to the "Knowledge" page and select "Connect to an External Knowledge Base" to access the configuration page. 2. **Configure Parameters**: - **Knowledge Base Name & Description**: Provide a name and description. - **External Knowledge API**: Choose the API for the external knowledge base. - **External Knowledge ID**: Specify the ID for the external knowledge base. - **Retrieval Setting**: - **Top K**: Set the number of relevant content chunks to retrieve (default is 3). - **Score Threshold**: Set the similarity threshold for filtering text chunks (default is 0.5). 3. **Set Up Endpoint**: Configure an endpoint for the retrieval API: ```plaintext POST <your-endpoint>/retrieval ``` 4. **Authorization**: Use an `API-Key` in the `Authorization` HTTP Header: ```plaintext Authorization: Bearer {API_KEY} ``` 5. **Request Body**: Send a JSON request with: - `knowledge_id`: Unique ID of your knowledge base. - `query`: User's query. - `retrieval_setting`: Object with `top_k` and `score_threshold`. 6. **Request Example**: ```json POST <your-endpoint>/retrieval HTTP/1.1 Content-Type: application/json Authorization: Bearer your-api-key { "knowledge_id": "your-knowledge-id", "query": "your question", "retrieval_setting": { "top_k": 2, "score_threshold": 0.5 } } ``` These steps will allow the external LLM to interact with the DIY knowledge base through agents <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/llms.txt)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/en/guides/knowledge-base/connect-external-knowledge.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=other)</sup>
Author
Owner

@AuTingU commented on GitHub (Feb 26, 2025):

你好,你的来信已收到!

@AuTingU commented on GitHub (Feb 26, 2025): 你好,你的来信已收到!
Author
Owner

@AuTingU commented on GitHub (Feb 26, 2025):

你好@AuTingU!我在这里帮助您修复错误、回答问题并支持您作为贡献者。让我们一起解决您遇到的任何问题。

要让外部 LLM 通过 Dify 中的代理使用 DIY 知识库,您需要遵循以下步骤:

  1. 连接到外部知识库:导航到“知识”页面并选择“连接到外部知识库”以访问配置页面。

  2. 配置参数

    • 知识库名称和描述:提供名称和描述。

    • 外部知识 API:选择外部知识库的 API。

    • 外部知识 ID:指定外部知识库的 ID。

    • 检索设置

      • Top K:设置要检索的相关内容块的数量(默认为 3)。
      • 分数阈值:设置过滤文本块的相似度阈值(默认为 0.5)。
  3. 设置端点:为检索 API 配置端点:

    POST <your-endpoint>/retrieval
    
  4. 授权API-Key:在 HTTP 标头中使用Authorization

    Authorization: Bearer {API_KEY}
    
  5. 请求正文:发送 JSON 请求,内容如下:

    • knowledge_id:您的知识库的唯一ID。
    • query:用户的查询。
    • retrieval_setting:带有top_k和 的对象score_threshold
  6. 请求示例
    POST /retrieval HTTP/1.1
    Content-Type: application/json
    Authorization: Bearer your-api-key

    {
    "knowledge_id": "your-knowledge-id",
    "query": "your question",
    "retrieval_setting": {
    "top_k": 2,
    "score_threshold": 0.5
    }
    }

这些步骤将允许外部 LLM 通过代理[1] [2]与 DIY 知识库进行交互。

要继续与Dosu交谈,请提及@dosu

帮助 Dosu 学习!提供反馈:很好的回应|不相关的答案|不正确的来源|太冗长|幻觉|错误报告|其他

POST /retrieval
How to generate your endpoint?

@AuTingU commented on GitHub (Feb 26, 2025): > 你好[@AuTingU](https://github.com/AuTingU)!我在这里帮助您修复错误、回答问题并支持您作为贡献者。让我们一起解决您遇到的任何问题。 > > 要让外部 LLM 通过 Dify 中的代理使用 DIY 知识库,您需要遵循以下步骤: > > 1. **连接到外部知识库**:导航到“知识”页面并选择“连接到外部知识库”以访问配置页面。 > 2. **配置参数**: > > * **知识库名称和描述**:提供名称和描述。 > * **外部知识 API**:选择外部知识库的 API。 > * **外部知识 ID**:指定外部知识库的 ID。 > * **检索设置**: > > * **Top K**:设置要检索的相关内容块的数量(默认为 3)。 > * **分数阈值**:设置过滤文本块的相似度阈值(默认为 0.5)。 > 3. **设置端点**:为检索 API 配置端点: > ``` > POST <your-endpoint>/retrieval > ``` > 4. **授权**`API-Key`:在 HTTP 标头中使用`Authorization`: > ``` > Authorization: Bearer {API_KEY} > ``` > 5. **请求正文**:发送 JSON 请求,内容如下: > > * `knowledge_id`:您的知识库的唯一ID。 > * `query`:用户的查询。 > * `retrieval_setting`:带有`top_k`和 的对象`score_threshold`。 > 6. **请求示例**: > POST <your-endpoint>/retrieval HTTP/1.1 > Content-Type: application/json > Authorization: Bearer your-api-key > > { > "knowledge_id": "your-knowledge-id", > "query": "your question", > "retrieval_setting": { > "top_k": 2, > "score_threshold": 0.5 > } > } > > [这些步骤将允许外部 LLM 通过代理[1] ](https://github.com/langgenius/dify-docs/blob/main/en/llms.txt)[[2]](https://github.com/langgenius/dify-docs/blob/main/en/guides/knowledge-base/connect-external-knowledge.md)与 DIY 知识库进行交互。 > > _要继续与[Dosu](https://dosu.dev)交谈,请提及[@dosu](https://github.com/dosu)。_ > > 帮助 Dosu 学习!提供反馈:[很好的回应](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=great_response)|[不相关的答案](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=irrelevant_answer)|[不正确的来源](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=incorrect_sources)|[太冗长](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=too_verbose)|[幻觉](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=hallucination)|[错误报告](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=bug_report)|[其他](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=other) POST <your-endpoint>/retrieval How to generate your endpoint?
Author
Owner

@AuTingU commented on GitHub (Feb 26, 2025):

I found it, please allow me to try it once, thank you

@AuTingU commented on GitHub (Feb 26, 2025): I found it, please allow me to try it once, thank you
Author
Owner

@AuTingU commented on GitHub (Feb 26, 2025):

Hello @AuTingU! I'm here to help you with bug fixes, answer questions, and support you as a contributor. Let's work together to solve any issues you encounter.

To enable an external LLM to use the DIY knowledge base through agents in Dify, you need to follow these steps:

  1. Connect to an External Knowledge Base: Navigate to the "Knowledge" page and select "Connect to an External Knowledge Base" to access the configuration page.

  2. Configure Parameters:

    • Knowledge Base Name & Description: Provide a name and description.

    • External Knowledge API: Choose the API for the external knowledge base.

    • External Knowledge ID: Specify the ID for the external knowledge base.

    • Retrieval Setting:

      • Top K: Set the number of relevant content chunks to retrieve (default is 3).
      • Score Threshold: Set the similarity threshold for filtering text chunks (default is 0.5).
  3. Set Up Endpoint: Configure an endpoint for the retrieval API:

    POST <your-endpoint>/retrieval
    
  4. Authorization: Use an API-Key in the Authorization HTTP Header:

    Authorization: Bearer {API_KEY}
    
  5. Request Body: Send a JSON request with:

    • knowledge_id: Unique ID of your knowledge base.
    • query: User's query.
    • retrieval_setting: Object with top_k and score_threshold.
  6. Request Example:
    POST /retrieval HTTP/1.1
    Content-Type: application/json
    Authorization: Bearer your-api-key

    {
    "knowledge_id": "your-knowledge-id",
    "query": "your question",
    "retrieval_setting": {
    "top_k": 2,
    "score_threshold": 0.5
    }
    }

These steps will allow the external LLM to interact with the DIY knowledge base through agents [1][2].

To continue talking to Dosu, mention @dosu.

Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Not connecting to an external knowledge base, but I want to access dify's knowledge base through an external LLM

@AuTingU commented on GitHub (Feb 26, 2025): > Hello [@AuTingU](https://github.com/AuTingU)! I'm here to help you with bug fixes, answer questions, and support you as a contributor. Let's work together to solve any issues you encounter. > > To enable an external LLM to use the DIY knowledge base through agents in Dify, you need to follow these steps: > > 1. **Connect to an External Knowledge Base**: Navigate to the "Knowledge" page and select "Connect to an External Knowledge Base" to access the configuration page. > 2. **Configure Parameters**: > > * **Knowledge Base Name & Description**: Provide a name and description. > * **External Knowledge API**: Choose the API for the external knowledge base. > * **External Knowledge ID**: Specify the ID for the external knowledge base. > * **Retrieval Setting**: > > * **Top K**: Set the number of relevant content chunks to retrieve (default is 3). > * **Score Threshold**: Set the similarity threshold for filtering text chunks (default is 0.5). > 3. **Set Up Endpoint**: Configure an endpoint for the retrieval API: > ``` > POST <your-endpoint>/retrieval > ``` > 4. **Authorization**: Use an `API-Key` in the `Authorization` HTTP Header: > ``` > Authorization: Bearer {API_KEY} > ``` > 5. **Request Body**: Send a JSON request with: > > * `knowledge_id`: Unique ID of your knowledge base. > * `query`: User's query. > * `retrieval_setting`: Object with `top_k` and `score_threshold`. > 6. **Request Example**: > POST <your-endpoint>/retrieval HTTP/1.1 > Content-Type: application/json > Authorization: Bearer your-api-key > > { > "knowledge_id": "your-knowledge-id", > "query": "your question", > "retrieval_setting": { > "top_k": 2, > "score_threshold": 0.5 > } > } > > These steps will allow the external LLM to interact with the DIY knowledge base through agents [[1]](https://github.com/langgenius/dify-docs/blob/main/en/llms.txt)[[2]](https://github.com/langgenius/dify-docs/blob/main/en/guides/knowledge-base/connect-external-knowledge.md). > > _To continue talking to [Dosu](https://dosu.dev), mention [@dosu](https://github.com/dosu)._ > > Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/6d2f29b6-3fc3-4464-a8c8-f70b49cbdbf9?feedback_type=other) Not connecting to an external knowledge base, but I want to access dify's knowledge base through an external LLM
Author
Owner

@crazywoola commented on GitHub (Feb 26, 2025):

For question, please use discussion instead.

@crazywoola commented on GitHub (Feb 26, 2025): For question, please use discussion instead.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8643