Connect an OSS data source
AI-Native Database Service supports synchronizing files from Alibaba Cloud Object Storage Service (OSS) to a RAGFlow knowledge base by using the KBSync tool. This topic describes how to configure KBSync to connect an OSS data source.
Supported file types
KBSync supports the following file types for synchronization from OSS to a RAGFlow knowledge base:
-
Documents: DOC, DOCX, PPT, PPTX, PDF, TXT, and MD.
-
Data: SQL, CSV, and XLSX.
-
Images: JPG, PNG, BMP, and GIF.
-
Audio: MP3 and WAV.
Prerequisites
-
A RAGFlow instance is created in the AI-Native Database Service console, and you have obtained the API URL and API key.
-
An AccessKey pair (AccessKey ID and AccessKey secret) with read permissions on OSS is obtained. For more information, see Create an AccessKey pair.
-
The name and region of the target OSS bucket are obtained.
-
A Linux server is prepared to run the KBSync tool.
-
A knowledge base is created in RAGFlow, and you have obtained the dataset ID of the knowledge base.
Procedure
Step 1: Download and install KBSync
-
Log on to the Linux server.
-
Download the KBSync package and extract it to the target directory.
-
Go to the KBSync directory and verify that it contains the
kbsyncexecutable and theconfig.yamlconfiguration template.
Step 2: Configure the OSS data source
Edit the config.yaml file and configure the OSS data source and RAGFlow destination parameters as described in the following table.
|
Parameter |
Description |
Example |
|
|
The type of the data source. Set this parameter to |
OSS |
|
|
The type of the destination. Set this parameter to |
RagFlow |
|
|
The AccessKey ID that has read permissions on OSS. |
LTAI5t**** |
|
|
The AccessKey secret that corresponds to the AccessKey ID. |
wJalr**** |
|
|
The name of the OSS bucket. |
my-doc-bucket |
|
|
The region where the OSS bucket resides. |
cn-hangzhou |
|
|
The API URL of the RAGFlow instance. |
http://ragflow.example.com/api |
|
|
The API key of the RAGFlow instance, used for authentication. |
ragflow-**** |
|
|
The dataset ID of the target knowledge base in RAGFlow. |
ds-abc123 |
Step 3: Configure file filtering rules (optional)
KBSync supports whitelists and blacklists to filter files in the OSS bucket. Only files that match the filtering criteria are synchronized.
|
Parameter |
Description |
|
|
The whitelist rule. Only files that match this rule are synchronized. Wildcards are supported. For example, |
|
|
The blacklist rule. Files that match this rule are excluded from synchronization. For example, |
If both the whitelist and blacklist are configured, the system first applies the whitelist to filter files, and then excludes files that match the blacklist from the results.
Step 4: Start the synchronization task
-
In the KBSync directory, run the following command to start the synchronization task:
./kbsync -c config.yaml -
Check the terminal output logs to verify that the task runs as expected. After the synchronization is complete, the logs display the number of synchronized files and the processing results.
-
Log on to the AI-Native Database Service console. In the left-side navigation pane, in the AI Data Preparation section, click Multimodal Data Preparation. Click the target RAGFlow instance to go to the details page. Verify that the files are imported.
Usage notes
-
KBSync runs only on Linux. Windows and macOS are not supported.
-
Make sure that the server where KBSync runs can access the OSS bucket endpoint and the RAGFlow API URL.
-
For large files that exceed 500 MB, run the synchronization on a server with sufficient network bandwidth.
-
KBSync supports incremental synchronization. When you run KBSync again, only new or updated files are synchronized. Files that already exist in the knowledge base are not reimported.