导出语义条目

导出知识库定义和语义条目,用于审阅或迁移。

GET https://api.moi.matrixorigin.cn/v5/semantic-models/{model_id}/export

调用前准备

先查询知识库列表取得知识库 ID。准备可访问目标工作区的个人访问令牌和目标工作区 ID。

请求体

将示例中的 $MODEL_ID、$AI_STUDIO_API_KEY、$WORKSPACE_ID 替换为实际值。

curl "https://api.moi.matrixorigin.cn/v5/semantic-models/$MODEL_ID/export" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"

参数

类型

是否必填

说明

model_id

integer

是

要导出定义的知识库 ID。

请求体

domain 支持 nl2sql 和 rag。创建和更新时,省略 domain 默认使用 nl2sql。查询列表时可按 domain 筛选。

  • nl2sql 支持下表列出的 8 种条目。

  • rag 仅支持 business_rule 和 standard_qa。

  • standard_qa 在 nl2sql 中填写单条只读 SQL,在 rag 中填写 answer。

响应中的 domain 为条目实际所属的域。

成功响应

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "model": {
      "id": 401,
      "name": "product_docs",
      "tables": null,
      "source_counts": {
        "files": 2,
        "tables": 1,
        "total": 3
      },
      "created_at": 0,
      "updated_at": 0
    },
    "entries": [
      {
        "id": 501,
        "domain": "nl2sql",
        "kind": "metric",
        "key": "total_rows",
        "tables": [
          "orders"
        ],
        "spec": {
          "name": "GMV",
          "metric_type": "aggregate",
          "aggregation": "SUM",
          "field": "amount"
        },
        "created_at": 0,
        "updated_at": 0
      }
    ]
  }
}

字段

类型

说明

data.model

object

知识库定义。

data.model.id

integer

标识。

data.model.name

string

名称。

data.model.description

string

说明。

data.model.tables

object(对象数组)

表引用。

data.model.files

object(对象数组)

文件配置。

data.model.source_counts

object

来源数量统计。

data.model.source_counts.files

integer

文件来源数量,不小于 0。

data.model.source_counts.tables

integer

数据表来源数量,不小于 0。

data.model.source_counts.total

integer

文件与表来源数量之和。不小于 0。

data.model.created_at

integer

创建时间。

data.model.updated_at

integer

更新时间。

data.entries

object(对象数组)

当前知识库中的语义条目。

data.entries[].id

integer

标识。

data.entries[].domain

string

条目的实际语义域。取值:nl2sql、rag。

data.entries[].kind

string

类别。取值:metric、table_description、field_description、business_rule、constraint、relationship、standard_qa、dynamic_query。

data.entries[].key

string

键。

data.entries[].tables

string(字符串数组)

表引用。

data.entries[].spec

object

类型对应配置。

data.entries[].sql_preview

string

SQL 预览。

data.entries[].created_at

integer

创建时间。

data.entries[].updated_at

integer

更新时间。

指标配置

字段

类型

说明

name

string

名称。

synonyms

string(字符串数组) 或 null

同义词。

description

string

说明。

source_table

string

来源表。

metric_type

string

指标类型。

aggregation

string

聚合函数。

field

string

字段。

filter

object 或 null

筛选树。

filter.type

string

类型。

filter.op

string

条件连接方式。

filter.children

object(对象数组) 或 null

子条件。

filter.field

string

字段。

filter.operator

string

比较操作符。

filter.value

any

值。

multiplier

number

乘数。

formula

object 或 null

公式树。

formula.type

string

类型。

formula.key

string

键。

formula.value

number 或 null

值。

formula.left

object 或 null

左操作数。

formula.right

object 或 null

右操作数。

筛选树

children 为同结构节点数组。按本节字段定义递归填写。

字段

类型

说明

type

string

类型。

op

string

条件连接方式。

children

object(对象数组) 或 null

子条件。

field

string

字段。

operator

string

比较操作符。

value

any

值。

公式树

left、right 为同结构公式节点。按本节字段定义递归填写。

字段

类型

说明

type

string

类型。

key

string

键。

value

number 或 null

值。

left

object 或 null

左操作数。

right

object 或 null

右操作数。

表说明配置

字段

类型

说明

table

string

表名称。

description

string

说明。

synonyms

string(字符串数组) 或 null

同义词。

字段说明配置

字段

类型

说明

table

string

表名称。

column

string

列名。

description

string

说明。

synonyms

string(字符串数组) 或 null

同义词。

nl2sql_enabled

boolean 或 null

是否启用自然语言转 SQL。

业务规则配置

字段

类型

说明

rule

string

业务规则。

files

string(字符串数组) 或 null

文件配置。

migration_status

string

迁移状态。

约束配置

字段

类型

说明

filter

object

筛选树。

filter.type

string

类型。

filter.op

string

条件连接方式。

filter.children

object(对象数组) 或 null

子条件。

filter.field

string

字段。

filter.operator

string

比较操作符。

filter.value

any

值。

description

string

说明。

表关联配置

字段

类型

说明

left_table

string

左表。

right_table

string

右表。

join_type

string

连接类型。

conditions

object(对象数组) 或 null

连接条件。

conditions[].operator

string

比较操作符。

conditions[].left

string

左操作数。

conditions[].right

string

右操作数。

description

string

说明。

连接条件

字段

类型

说明

operator

string

比较操作符。

left

string

左操作数。

right

string

右操作数。

标准问答配置

字段

类型

说明

question

string

问题。

similar_questions

string(字符串数组) 或 null

相似问题。

sql

string

SQL 文本。

answer

string

回答。

usage_mode

string

使用方式。

files

string(字符串数组) 或 null

文件配置。

description

string

说明。

synonyms

string(字符串数组) 或 null

同义词。

动态查询配置

字段

类型

说明

query_key

string

查询键。

sql

string

SQL 文本。

description

string

说明。

handling

string

处理方式。

错误响应

{
  "code": "ErrNotFound",
  "msg": "resource not found",
  "data": null
}

字段

类型

说明

code

string

错误代码。

msg

string

错误说明。

data

null

发生错误时为 null。

最后更新于