Tutorial: Use a DTS RAGFlow knowledge base as an external Dify knowledge base

更新时间:
复制 MD 格式

This topic describes how to use a Data Transmission Service (DTS) RAGFlow knowledge base as an external knowledge base in DMS Dify to develop large language model (LLM) applications.

Prerequisites

  • You have created a RAGFlow knowledge base and configured its IP whitelist and created and started a Dify resource.

    Important
    • To use an internal network connection, your DTS RAGFlow knowledge base and DMS Dify resource must be in the same Virtual Private Cloud (VPC).

    • To use a public network connection, the Virtual Private Cloud (VPC) where your DTS RAGFlow knowledge base resides must have a NAT gateway to be accessible over the public internet.

  • You have completed the required configurations on the RAGFlow page, such as adding a model provider.

Procedure

Step 1: Create a knowledge base and upload files

  1. Log on to the RAGFlow page.

  2. Create a knowledge base.

    1. In the upper-right corner of the page, click Create Knowledge Base.

    2. In the Create Knowledge Base dialog box, enter a Name for the knowledge base.

    3. Click OK.

    4. Configure the knowledge base and click Save.

  3. Upload files to the knowledge base.

    1. On the Dataset page of the knowledge base, select New File > Local File.

    2. In the File dialog box, select and upload your local files.

    3. Select the Parse When Creating checkbox.

    4. Click OK.

Step 2: Add and connect the external knowledge base

  1. Go to the Knowledge Base page in DMS.

    Note

    For instructions on how to access this page, contact DMS technical support.

    On the Knowledge Base page, click the Connect to External Knowledge Base → link at the bottom of the + Create Knowledge Base card.

  2. Add an external knowledge base API.

    1. On the right side of the page, click External Knowledge Base API.

    2. Click Add External Knowledge Base API.

    3. Configure the external knowledge base API information.

      Parameter

      Description

      Name

      Enter a descriptive name for easy identification.

      API endpoint

      The API endpoint of the DTS RAGFlow knowledge base, in the format http://<IP>/api/v1/dify.

      Note
      • Replace <IP> with the connection address of the DTS RAGFlow knowledge base.

      • If you use the Knowledge Base Intranet Address, you must add the IPv4 CIDR block of the vSwitch where DMS Dify is located to the IP whitelist of the DTS RAGFlow knowledge base. If you use the Knowledge Base External Network Address, you must also add the public egress IP address of DMS Dify to the IP whitelist of the DTS RAGFlow knowledge base.

      API key

      The API key for the RAGFlow knowledge base.

    4. Click Save.

  3. Connect the external knowledge base.

    1. In the External Knowledge Base API panel on the right side of the page, click the refresh icon image.

    2. In the Create Knowledge Base card, click Connect External Knowledge Base.

    3. Configure the external knowledge base information.

      Parameter

      Description

      External knowledge base name

      Enter a descriptive name for the external knowledge base.

      Knowledge Base Description (Optional)

      Enter a description for the external knowledge base.

      External knowledge base API

      Select the external knowledge base API you added in step 2.

      External knowledge base ID

      Enter the ID of the external knowledge base.

      Note

      To obtain the ID, see Obtain the ID of the RAGFlow knowledge base.

      Retrieval settings

      Set the Top K and score threshold values.

    4. Click Connect.

      A card with the name you entered for the External knowledge base name appears on the DMS Knowledge Base page.

Step 3: Build workflows and applications

In the DMS console, you can now use this knowledge base to develop LLM applications.

Note

Appendix

Obtain the connection address

  1. Go to the RAGFlow knowledge base list page for the destination region.

    1. Log on to the Data Transmission Service (DTS) console.

    2. In the left-side navigation pane, click Data Preparation.

    3. In the upper-left corner, select the region where the data preparation instance resides.

    4. Click the RAGFlow knowledge base tab.

  2. In the Actions column for the target RAGFlow knowledge base, click Manage.

  3. In the Endpoint section, copy the Knowledge Base Intranet Address or Knowledge Base External Network Address.

Obtain the API key

  1. Log on to the RAGFlow page.

  2. In the navigation pane on the left, click API.

  3. To the right of RAGFlow API, click API KEY.

  4. In the API KEY dialog box, click Create New Key.

  5. Click image to copy the key, and then save it in a secure location.

Obtain the knowledge base ID

  1. Log on to the RAGFlow page.

  2. On the Knowledge Base page, click the target knowledge base.

  3. In the URL in your browser's address bar, copy the knowledge base ID.

    Note

    The knowledge base ID is the string of characters that follows id=.

Create and use a Chat Assistant application

  1. Create a Chat Assistant application.

    1. On the DMS Knowledge Base page, click the Studio tab.

    2. Click Chat Assistant.

    3. In the Create Application card, click Create Blank Application.

    4. Configure the application information.

      Parameter

      Description

      Select application type

      Select Chat Assistant.

      Application name & icon

      Enter a name and choose an icon for the Chat Assistant application.

      Description (Optional)

      Enter a description for the Chat Assistant application.

    5. Click Create.

  2. Click the Chat Assistant application that you created.

  3. Orchestrate the Chat Assistant application.

    1. Enter a prompt.

    2. In the Knowledge Base section, click Add.

    3. Select the external knowledge base that you configured in Step 2, and then click Add.

    4. Configure the Retrieval settings as needed, and then click Save.

    5. In the upper-right corner of the page, select the model for the Chat Assistant application.

  4. In the Chat with bot text box, enter a question to test the application.