创建知识库前预览数据

在创建知识库前,根据 Catalog 选择范围预览将选中的文件和数据表数量。该接口只读,不会创建知识库、数据源或处理任务。

POST https://api.moi.matrixorigin.cn/v5/semantic-models/source-selections/preview

调用前准备

选择范围仅支持 Catalog 数据:database_tables 用于一个 Database 中的数据表,volume_files 用于一个 Volume 中的文件。all_selected: false 时必须传对应的 selected_table_idsselected_file_idsall_selected: true 时可传对应的排除 ID。

请求参数

curl -X POST "https://api.moi.matrixorigin.cn/v5/semantic-models/source-selections/preview" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "source_selections": [
      {
        "kind": "database_tables",
        "database_id": 101,
        "all_selected": false,
        "selected_table_ids": [201]
      }
    ]
  }'

字段路径中的 [] 表示数组中的每一项。例如,source_selections[].kind 表示 source_selections 数组中每一项的 kind 字段。

字段

类型

必填

说明

source_selections

array of object

要预览的来源选择。

下面表格展开请求示例中 source_selections 数组的每一项;每一行是该数组项的一个字段。

字段

类型

必填

说明

kind

string

database_tablesvolume_files

database_id

integer

条件必填

database_tables 的 Catalog Database ID。

volume_id

integer

条件必填

volume_files 的 Catalog Volume ID。

all_selected

boolean

true 选择当前范围内全部对象;false 时必须提供对应的显式选择 ID。

selected_table_ids

array of integer

条件必填

all_selectedfalse 时,显式选中的 Catalog 表 ID。

selected_file_ids

array of string

条件必填

all_selectedfalse 时,显式选中的 Catalog 文件 ID。

excluded_table_ids

array of integer

全选时要排除的 Catalog 表 ID。

excluded_file_ids

array of string

全选时要排除的 Catalog 文件 ID。

filters

object

按表名、文件名或扩展名进一步筛选。

下面表格展开请求示例中 source_selections[].filters 对象;每一行是该对象的一个字段。

字段

类型

必填

说明

table_name

string

表名筛选条件。

file_name

string

文件名筛选条件。

file_ext

array of string

文件扩展名筛选条件。

成功响应

成功时返回 200

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "file_count": 0,
    "table_count": 1,
    "total_count": 1
  }
}

字段

类型

说明

code

string

成功时为 OK

msg

string

成功时为 OK

data

object

响应数据。

下面表格展开响应示例中 data 对象;每一行是该对象的一个字段。

字段

类型

说明

file_count

integer

预览范围中的文件数量。

table_count

integer

预览范围中的数据表数量。

total_count

integer

去重后的总数量。

后续操作

数量符合预期后,使用相同的 source_selections 调用创建知识库并添加数据源

最后更新于