检索知识库
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| KbUuid |
string |
是 |
知识库 ID。 |
kb-*** |
| Query |
string |
是 |
查询内容。 |
What is GraphRAG? |
| TopK |
integer |
否 |
返回 top 数量的结果。 |
10 |
| Filter |
string |
否 |
要查询的数据的过滤条件,格式为 SQL 的 WHERE 格式。 |
title = 'test' AND name like 'test%' |
| Metrics |
string |
否 |
检索时的相似度算法。此值为空时则采用创建知识库时指定的算法,建议如无特殊需求不需设置。 可选值:
|
cosine |
| HybridSearch |
string |
否 |
多路召回算法,默认为空(即直接将稠密向量和全文的分数比较并排序)。 可选值:
|
RRF |
| HybridSearchArgs |
string |
否 |
多路召回的算法参数。目前支持 RRF 和 Weight 两种。HybridPathsSetting 可以指定召回稠密向量(dense)、稀疏向量(sparse)和全文检索(fulltext),如果值为空,默认召回稠密向量(dense)和全文检索(fulltext)。
|
{ \"Weight\": { \"alpha\": 0.5 } } |
| IncludeVector |
boolean |
否 |
是否返回向量。默认为 false。 说明
|
false |
| IncludeMetadataFields |
string |
否 |
默认为空,表示要返回的 metadata 字段,多个字段用逗号分隔。 |
title,page |
| RerankFactor |
number |
否 |
重排因子。当该值不为空时,会对向量检索结果再做一次重排。取值范围:1<RerankFactor<=5。 说明
|
2 |
| RecallWindow |
string |
否 |
召回窗口。当该值不为空时,增加返回检索结果的上下文。格式为 2 个元素的数组:List<A, B>,其中-10<=A<=0,0<=B<=10。 说明
|
[-5,5] |
| OrderBy |
string |
否 |
默认为空,表示排序的依据字段。 字段必须属于 metadata 或表里的默认字段比如 id,格式支持: 单个字段,如 chunk_id; 多个字段,用逗号连接,如 block_id, chunk_id; 支持反序,如: block_id DESC, chunk_id DESC; |
created_at |
| Offset |
integer |
否 |
偏移量,用于分页查询 |
0 |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
Schema of Response |
||
| RequestId |
string |
本次调用的唯一 ID。出现错误后,您可以根据该 ID 排查问题。 |
67E910F2-4B62-5B0C-ACA3-7547695C**** |
| Data |
object |
返回结构体。 |
|
| Results |
array<object> |
结果列表。 |
|
|
array<object> |
返回数据。 |
||
| Id |
string |
向量数据的唯一 Id。 |
3b35c95-57f3-442f-9220-xxxxx |
| Content |
string |
文本内容。 |
GraphRAG (Graph Retrieval-Augmented Generation) is an advanced AI framework that combines Knowledge Graphs with Large Language Models (LLMs) to improve the accuracy, context, and reasoning capabilities of information retrieval and generation. |
| FileName |
string |
文档名称。 |
1.txt |
| LoaderMetadata |
string |
文档加载器加载时的元信息。 |
{"page_pos": 1} |
| Score |
number |
此条数据的相似度分数,其分数算法和创建索引时指定的算法(l2/ip/cosine)相关。 |
0.81 |
| Vector |
array |
向量数据列表。 |
|
|
number |
向量数据。 |
1.2123 |
|
| Metadata |
object |
元数据 Map。 |
{"title":"test"} |
| RerankScore |
number |
重排分数。 |
6.2345 |
| RetrievalSource |
integer |
检索结果的来源。1 表示向量检索,2 表示全文检索,3 表示双路召回。 |
1 |
| Matches |
array<object> |
窗口化匹配到的列表。 |
|
|
array<object> |
返回数据。 |
||
| Content |
string |
文本内容。 |
GraphRAG (Graph Retrieval-Augmented Generation) is an advanced AI framework that combines Knowledge Graphs with Large Language Models (LLMs) to improve the accuracy, context, and reasoning capabilities of information retrieval and generation. |
| FileName |
string |
文档名称。 |
1.txt |
| Id |
string |
向量数据的唯一 Id。 |
3b35c95-57f3-442f-9220-xxxxx |
| LoaderMetadata |
string |
文档加载器加载时的元信息。 |
{"page_pos": 1} |
| Metadata |
object |
元数据 Map。 |
{"title":"test"} |
| ErrorCode |
string |
错误码,请求异常时返回。 |
KnowledgeBaseNotFound |
| Success |
boolean |
请求是否成功,返回值如下:
|
true |
| ErrorMessage |
string |
调用失败时,返回的错误信息。 |
Resource not found kb-*** |
示例
正常返回示例
JSON格式
{
"RequestId": "67E910F2-4B62-5B0C-ACA3-7547695C****",
"Data": {
"Results": [
{
"Id": "3b35c95-57f3-442f-9220-xxxxx",
"Content": "GraphRAG (Graph Retrieval-Augmented Generation) is an advanced AI framework that combines Knowledge Graphs with Large Language Models (LLMs) to improve the accuracy, context, and reasoning capabilities of information retrieval and generation.",
"FileName": "1.txt",
"LoaderMetadata": "{\"page_pos\": 1}",
"Score": 0.81,
"Vector": [
1.2123
],
"Metadata": {
"title": "test"
},
"RerankScore": 6.2345,
"RetrievalSource": 1
}
],
"Matches": [
{
"Content": "GraphRAG (Graph Retrieval-Augmented Generation) is an advanced AI framework that combines Knowledge Graphs with Large Language Models (LLMs) to improve the accuracy, context, and reasoning capabilities of information retrieval and generation.",
"FileName": "1.txt",
"Id": "3b35c95-57f3-442f-9220-xxxxx",
"LoaderMetadata": "{\"page_pos\": 1}",
"Metadata": {
"title": "test"
}
}
]
},
"ErrorCode": "KnowledgeBaseNotFound",
"Success": true,
"ErrorMessage": "Resource not found kb-***"
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。