创建空知识库

创建空知识库。创建后可单独添加数据源和语义条目。

POST https://moi.matrixorigin.cn/newmoi/semantic-models

调用前准备

准备有目标工作区访问权限且具有创建知识库权限的个人访问令牌和目标工作区 ID。

请求体

curl -X POST "https://moi.matrixorigin.cn/newmoi/semantic-models" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "<KNOWLEDGE_BASE_NAME>",
    "description": "<DESCRIPTION>",
    "tables": []
  }'

字段

类型

必填

说明

name

string

知识库名称。

description

string

覆盖范围和使用说明。

tables

array of object

兼容的旧式表来源定义。新接入来源请使用添加数据源接口。

files

object

兼容的旧式文件来源配置。新接入来源请使用添加数据源接口。

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

字段

类型

必填

说明

db_name

string

条件必填

表来源所在的数据库名称。

table_names

array of string

条件必填

该数据库中要纳入知识库的表名称。

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

字段

类型

必填

说明

file_ids

array of string

文件 ID;创建知识库时服务端不保留此字段,应改用添加数据源接口。

parents

array of string

文件来源的父路径。

volume_ids

array of string

文件来源的卷 ID。

volumes

array of object

文件来源卷及路径。

vector_table

string

向量表名称;服务端可补齐默认值。

embedding_model

string

Embedding 模型标识;服务端可补齐默认值。

tags

array of string

文件来源标签。

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

字段

类型

必填

说明

volume_id

string

条件必填

卷 ID。

parents

array of string

卷来源的父路径。

path

array of string

卷内文件路径。

成功响应

成功时返回 201。保存 data.id,后续接口将它作为 model_id 使用。

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "id": 401,
    "name": "product_docs",
    "description": "产品文档",
    "tables": [],
    "source_counts": {
      "files": 0,
      "tables": 0,
      "total": 0
    },
    "created_at": 1735632000,
    "updated_at": 1735632000
  }
}

字段

类型

说明

code

string

成功时为 OK

msg

string

成功时为 OK

data

object

响应数据。

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

字段

类型

说明

id

integer

新知识库 ID。

name

string

已创建的知识库名称。

description

string

已保存的说明;未设置时可能省略。

tables

array of object

兼容的旧式表来源定义。

files

object

兼容的旧式文件来源定义。

source_counts

object

创建快照中的来源计数;空知识库各项为 0

created_at

integer

Unix 时间戳。

updated_at

integer

Unix 时间戳。

下面表格展开响应示例中 data.tables 数组的每一项;每一行是该数组项的一个字段。

字段

类型

说明

db_name

string

表来源所在的数据库名称。

table_names

array of string

该数据库中纳入知识库的表名称。

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

字段

类型

说明

file_ids

array of string

文件 ID。

parents

array of string

文件来源的父路径。

volume_ids

array of string

文件来源的卷 ID。

volumes

array of object

文件来源卷及路径。

vector_table

string

向量表名称。

embedding_model

string

Embedding 模型标识。

tags

array of string

文件来源标签。

下面表格展开响应示例中 data.files.volumes 数组的每一项;每一行是该数组项的一个字段。

字段

类型

说明

volume_id

string

卷 ID。

parents

array of string

卷来源的父路径。

path

array of string

卷内文件路径。

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

字段

类型

说明

files

integer

文件来源数。

tables

integer

表来源数。

total

integer

来源总数。

错误响应

{
  "code": "ErrParamInvalid",
  "msg": "name is required",
  "data": null
}

字段

类型

说明

code

string

错误代码。

msg

string

面向调用者的错误信息。

data

null

发生错误时为 null

后续操作

使用 data.id 添加数据源上传本地文件

最后更新于