Transfer data from Alibaba Cloud Object Storage Service (OSS) to a RAGFlow knowledge base in Data Transmission Service (DTS).
Prerequisites
You have created a RAGFlow knowledge base in DTS and configured an IP whitelist.
Supported file types
-
DOC, DOCX, PPT, PPTX, YML, XML, HTML, JSON, CSV, TXT, XLS, XLSX, WPS, RTF, MD, SQL
-
JPG, JPEG, PNG
-
INI
-
MP3
Before you begin
-
Create an AccessKey and record the AccessKey ID and AccessKey secret.
NoteIf you use an AccessKey created by a RAM user, ensure that the RAM user has the AliyunOSSReadOnlyAccess (read-only access to OSS) or AliyunOSSFullAccess (full management access to OSS) permission.
-
Obtain and record your OSS bucket information, including the bucket name and region ID.
-
Log on to the OSS console.
-
In the left-side navigation pane, click Buckets.
-
Find the target bucket.
-
Record the Bucket Name of the target bucket.
-
Based on the Region of the target bucket, find and record the corresponding region ID.
-
Procedure
-
Obtain the KBSync file.
NoteYou can join the DingTalk group (ID: 79690034672) and contact technical support to obtain the KBSync file.
-
Prepare the runtime environment for the KBSync program.
NoteThe KBSync program must run in a Linux environment with network access to both OSS and RAGFlow.
-
Prepare the config file.
-
Create a Linux system file named config.
-
Copy the following code to the config file.
whiteList= blackList= sinkType=RagFlow sourceType=OSS ragflowUrl=http://XX.XX.XX.XX ragflowApiKey=Bearer ragflow-Rh****** ragflowDatasetId=****** sourceOSSAccessKeyId=****** sourceOSSAccessKeySecret=****** sourceOSSRegion=cn-beijing sourceOSSBucket=kbsync -
Update the parameters in the config file.
Important-
If a parameter is not required, leave its value empty.
-
The
blackListparameter has a higher priority than thewhiteListparameter.
Parameter
Required
Description
Source
whiteListNo
The paths of files or folders to include (whitelist) or exclude (blacklist), including folder paths in DingTalk Drive and document paths within the knowledge base.
NoteRegular expressions are supported. Separate multiple paths with spaces.
Obtain the path from OSS.
blackListsinkTypeYes
The sink type.
Set this parameter to
RagFlow.sourceTypeThe source type.
Set this parameter to
OSS.ragflowUrlThe RAGFlow endpoint (API server) address.
ragflowApiKeyThe API key of the RAGFlow knowledge base.
ImportantThe value must start with
Bearer. For example:Bearer ragflow-RhMjc0NjFhNTZmNTExZjBiYWY****.ragflowDatasetIdThe ID of the RAGFlow knowledge base.
sourceOSSAccessKeyIdThe AccessKey ID you recorded.
sourceOSSAccessKeySecretThe AccessKey secret you recorded.
sourceOSSRegionThe OSS region ID you recorded.
sourceOSSBucketThe OSS bucket name you recorded.
-
-
-
Place the KBSync file and the config configuration file in the same directory in a Linux environment.
-
In your Linux environment, run the
./KBSync --config configcommand to start the KBSync program.The KBSync program runs correctly if the output is similar to the following.
INFO config SourceType=OSS, SinkType=RagFlow INFO config whiteList=, blackList= INFO config ragflowUrl=http://XX.XX.XX.XX ragflowApiKey=Bearer ragflow-Rh****** INFO config ragflowDatasetId=b2****** INFO config sourceOssKeyId=******, sourceOssRegion=cn-beijing INFO Verifying RAGFlow connection... INFO Attempting to list datasets to validate the connection... INFO Successfully found matching dataset: Name='test', ID='b2******' INFO RAGFlow connection verified successfully.
Appendix
RAGFlow API server address
-
In the navigation pane on the left, click API.
-
Obtain the API server.
RAGFlow 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.
RAGFlow 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=.