更新时间:2024-02-18 GMT+08:00
分享

知识库数据查询

功能介绍

知识库数据查询接口。

URI

POST /v1/embedDataSet/queryEmbedData/{uuid}

表1 路径参数

参数

是否必选

参数类型

描述

uuid

String

知识库页面复制的Embedding API中的uuid。

请求参数

表2 请求Body参数

参数

是否必选

参数类型

描述

filter

Object

过滤条件。

is_cal_L2Distance

Boolean

是否计算向量距离,默认取false。取true时会默认按照向量距离降序排序。

limit

String

数据条目限制,默认为100条。

order_by

Object

排序条件。

query

String

查询内容。

响应参数

状态码: 200

表3 响应Body参数

参数

参数类型

描述

body

Array of results objects

返回体body参数,列表类型。

code

String

响应状态id

msg

String

响应状态

表4 results

参数

参数类型

描述

id

String

数据唯一id。

document

String

文档知识库:切分后的文档内容;图片知识库。

metadata

Object

metadata用于过滤。

uuid

String

数据唯一id。

dist

Number

向量距离。

表5 metadata

参数

参数类型

描述

file_id

String

文件id。(默认)。

file_name

String

完整文件名。(默认)。

order

Integer

段落在全文中切分后的顺序。

source

String

文件路径。文件上传时仅为文件名,数据接入时为除去’obs路径’后的路径值。

source_path

String

文件路径。

请求示例

https://{endpoint}/v1/embedDataSet/queryEmbedData/{uuid}

{
  "query" : "介绍",
  "limit" : "10",
  "is_cal_L2Distance" : true,
  "filter" : {
    "and" : [ {
      "expression" : {
        "field" : "metadata.file_id",
        "operation" : "in",
        "value" : [ "tes-t_1", "test_2" ]
      }
    }, {
      "expression" : {
        "field" : "dist",
        "operation" : "<=",
        "value" : [ "40", "30" ]
      }
    } ]
  }
}

响应示例

状态码: 200

OK

{
  "code" : "0",
  "msg" : "success!",
  "body" : [ {
    "results" : "{\"id\":null,\"document\"            :\"AppStage平台提供运营中心、运维中心、开发中心、AI中心等服务,其中AI中心(WisepilotStack)目前支持数据接            入以及管理,提示语管理,模型微调以及应用编排等功能\",\"metadata\":{\"file_id\":\"AppStage_常见问题\"            ,\"file_name\":\"AppStage_常见问题.docx\",\"order\":42,\"source\":\"AppStage_常见问题.docx\"            ,\"source_path\":\"AppStage_常见问题.docx\"},\"uuid\":\"d30ad89f-8162-462a-9486-c4e90a552f27\",\"dist\":0            .24643265061367536}"
  }, {
    "results" : "{\"id\":null,\"document\"            :\"AppStage平台是什么?\\nAppStage平台由华为云研发,提供运营中心、运维中心、开发中心、AI中心服务的平台,其            中AI中心(WisepilotStack)是由\",\"metadata\":{\"file_id\":\"AppStage_常见问题\",\"file_name\"            :\"AppStage_常见问题.docx\",\"order\":40,\"source\":\"AppStage_常见问题.docx\",\"source_path\"            :\"AppStage_常见问题.docx\"},\"uuid\":\"023149c8-d109-4bab-acef-a17c65f8d455\",\"dist\":0            .2554842085986647}"
  }, {
    "results" : "{\"id\":null,\"document\"            :\"华为云SmartStage团队AI部门研发,包含了数据接入,提示语管理,模型微调以及管理,应用编排等功能。\\nAppSta            ge平台目前有哪些产品功能?\",\"metadata\":{\"file_id\":\"AppStage_常见问题\",\"file_name\"            :\"AppStage_常见问题.docx\",\"order\":41,\"source\":\"AppStage_常见问题.docx\",\"source_path\"            :\"AppStage_常见问题.docx\"},\"uuid\":\"4df4528c-92de-460a-bfa1-515bfe7472bd\",\"dist\":0            .32361903803934944}"
  } ]
}

状态码

状态码

描述

200

OK

201

Created

401

Unauthorized

403

Forbidden

404

Not Found

错误码

请参见错误码

分享:

    相关文档

    相关产品