Connect an OSS data source

Updated at:
Copy as MD

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

  1. Log on to the Linux server.

  2. Download the KBSync package and extract it to the target directory.

  3. Go to the KBSync directory and verify that it contains the kbsync executable and the config.yaml configuration 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

sourceType

The type of the data source. Set this parameter to OSS.

OSS

sinkType

The type of the destination. Set this parameter to RagFlow.

RagFlow

accessKeyId

The AccessKey ID that has read permissions on OSS.

LTAI5t****

accessKeySecret

The AccessKey secret that corresponds to the AccessKey ID.

wJalr****

bucket

The name of the OSS bucket.

my-doc-bucket

region

The region where the OSS bucket resides.

cn-hangzhou

ragflowApiUrl

The API URL of the RAGFlow instance.

http://ragflow.example.com/api

ragflowApiKey

The API key of the RAGFlow instance, used for authentication.

ragflow-****

datasetId

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

whitelist

The whitelist rule. Only files that match this rule are synchronized. Wildcards are supported. For example, *.pdf,*.docx synchronizes only PDF and DOCX files.

blacklist

The blacklist rule. Files that match this rule are excluded from synchronization. For example, temp/*,*.tmp excludes all files in the temp directory and all temporary files.

Note

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

  1. In the KBSync directory, run the following command to start the synchronization task:

    ./kbsync -c config.yaml
  2. 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.

  3. 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.