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
-
Create a knowledge base.
-
In the upper-right corner of the page, click Create Knowledge Base.
-
In the Create Knowledge Base dialog box, enter a Name for the knowledge base.
-
Click OK.
-
Configure the knowledge base and click Save.
-
-
Upload files to the knowledge base.
-
On the Dataset page of the knowledge base, select .
-
In the File dialog box, select and upload your local files.
-
Select the Parse When Creating checkbox.
-
Click OK.
-
Step 2: Add and connect the external knowledge base
-
Go to the Knowledge Base page in DMS.
NoteFor 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.
-
Add an external knowledge base API.
-
On the right side of the page, click External Knowledge Base API.
-
Click Add External Knowledge Base API.
-
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.
NoteTo obtain the key, see Obtain the API key for the RAGFlow knowledge base.
-
-
Click Save.
-
-
Connect the external knowledge base.
-
In the External Knowledge Base API panel on the right side of the page, click the refresh icon
. -
In the Create Knowledge Base card, click Connect External Knowledge Base.
-
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.
NoteTo obtain the ID, see Obtain the ID of the RAGFlow knowledge base.
Retrieval settings
Set the Top K and score threshold values.
-
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.
-
For an example of application development, see Create and use a Chat Assistant application.
-
For more information, see the official Dify documentation.
Appendix
Obtain the connection address
-
Go to the RAGFlow knowledge base list page for the destination region.
-
Log on to the Data Transmission Service (DTS) console.
-
In the left-side navigation pane, click Data Preparation.
-
In the upper-left corner, select the region where the data preparation instance resides.
-
Click the RAGFlow knowledge base tab.
-
-
In the Actions column for the target RAGFlow knowledge base, click Manage.
-
In the Endpoint section, copy the Knowledge Base Intranet Address or Knowledge Base External Network Address.
Obtain the API key
-
In the navigation pane on the left, click API.
-
To the right of RAGFlow API, click API KEY.
-
In the API KEY dialog box, click Create New Key.
-
Click
to copy the key, and then save it in a secure location.
Obtain the knowledge base ID
-
On the Knowledge Base page, click the target knowledge base.
-
In the URL in your browser's address bar, copy the knowledge base ID.
NoteThe knowledge base ID is the string of characters that follows
id=.
Create and use a Chat Assistant application
-
Create a Chat Assistant application.
-
On the DMS Knowledge Base page, click the Studio tab.
-
Click Chat Assistant.
-
In the Create Application card, click Create Blank Application.
-
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.
-
Click Create.
-
-
Click the Chat Assistant application that you created.
-
Orchestrate the Chat Assistant application.
-
Enter a prompt.
-
In the Knowledge Base section, click Add.
-
Select the external knowledge base that you configured in Step 2, and then click Add.
-
Configure the Retrieval settings as needed, and then click Save.
-
In the upper-right corner of the page, select the model for the Chat Assistant application.
-
-
In the Chat with bot text box, enter a question to test the application.