全模态知识库检索
curl --request POST \
--url https://open.bigmodel.cn/api/zrag/retrieval/retrieve \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"multimodal": true,
"knows": [
{
"id": "1234567890"
}
],
"query": "介绍一下小智",
"multimodal_parts": [
{
"type": "image_url",
"url": "https://example.com/image.png"
}
],
"top_k": 8,
"top_n": 10,
"recall_method": "mixed",
"recall_ratio": 0.8,
"messages": [
{
"role": "user",
"content": "你是谁"
},
{
"role": "assistant",
"content": "我是小智,一个智能助手"
}
]
}
'import requests
url = "https://open.bigmodel.cn/api/zrag/retrieval/retrieve"
payload = {
"multimodal": True,
"knows": [{ "id": "1234567890" }],
"query": "介绍一下小智",
"multimodal_parts": [
{
"type": "image_url",
"url": "https://example.com/image.png"
}
],
"top_k": 8,
"top_n": 10,
"recall_method": "mixed",
"recall_ratio": 0.8,
"messages": [
{
"role": "user",
"content": "你是谁"
},
{
"role": "assistant",
"content": "我是小智,一个智能助手"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
multimodal: true,
knows: [{id: '1234567890'}],
query: '介绍一下小智',
multimodal_parts: [{type: 'image_url', url: 'https://example.com/image.png'}],
top_k: 8,
top_n: 10,
recall_method: 'mixed',
recall_ratio: 0.8,
messages: [{role: 'user', content: '你是谁'}, {role: 'assistant', content: '我是小智,一个智能助手'}]
})
};
fetch('https://open.bigmodel.cn/api/zrag/retrieval/retrieve', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://open.bigmodel.cn/api/zrag/retrieval/retrieve")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"multimodal\": true,\n \"knows\": [\n {\n \"id\": \"1234567890\"\n }\n ],\n \"query\": \"介绍一下小智\",\n \"multimodal_parts\": [\n {\n \"type\": \"image_url\",\n \"url\": \"https://example.com/image.png\"\n }\n ],\n \"top_k\": 8,\n \"top_n\": 10,\n \"recall_method\": \"mixed\",\n \"recall_ratio\": 0.8,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"你是谁\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"我是小智,一个智能助手\"\n }\n ]\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://open.bigmodel.cn/api/zrag/retrieval/retrieve"
payload := strings.NewReader("{\n \"multimodal\": true,\n \"knows\": [\n {\n \"id\": \"1234567890\"\n }\n ],\n \"query\": \"介绍一下小智\",\n \"multimodal_parts\": [\n {\n \"type\": \"image_url\",\n \"url\": \"https://example.com/image.png\"\n }\n ],\n \"top_k\": 8,\n \"top_n\": 10,\n \"recall_method\": \"mixed\",\n \"recall_ratio\": 0.8,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"你是谁\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"我是小智,一个智能助手\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://open.bigmodel.cn/api/zrag/retrieval/retrieve",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'multimodal' => true,
'knows' => [
[
'id' => '1234567890'
]
],
'query' => '介绍一下小智',
'multimodal_parts' => [
[
'type' => 'image_url',
'url' => 'https://example.com/image.png'
]
],
'top_k' => 8,
'top_n' => 10,
'recall_method' => 'mixed',
'recall_ratio' => 0.8,
'messages' => [
[
'role' => 'user',
'content' => '你是谁'
],
[
'role' => 'assistant',
'content' => '我是小智,一个智能助手'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"data": {
"contents": [
{
"id": "<string>",
"know_id": "<string>",
"doc_id": "<string>",
"text": "<string>",
"medias": [
{
"id": "<string>",
"url": "<string>",
"description": "<string>"
}
],
"image_url": {
"url": "<string>"
},
"video_url": {
"url": "<string>"
},
"index": 123,
"score": 123,
"rerank_index": 123,
"rerank_score": 123,
"metadata": {
"doc_type": "<string>",
"doc_name": "<string>",
"doc_url": "<string>",
"index": 123,
"page_index": 123,
"clip_index": 123,
"start_time": 123,
"end_time": 123,
"duration": 123,
"frames": [
"<string>"
]
}
}
],
"rewritten_query": {
"original_query": "<string>",
"multi_queries": [
"<string>"
]
},
"elapsed_ms": 123,
"total_tokens": 123,
"request_id": "<string>"
},
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}知识库 API
全模态知识库检索
用于检索全模态知识库,支持文本、图片、视频等多模态输入检索,支持向量检索、关键词检索、混合检索,支持查询重写、重排、QA干预等高级功能。点击 Try it 按钮可快速试用。
POST
/
zrag
/
retrieval
/
retrieve
全模态知识库检索
curl --request POST \
--url https://open.bigmodel.cn/api/zrag/retrieval/retrieve \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"multimodal": true,
"knows": [
{
"id": "1234567890"
}
],
"query": "介绍一下小智",
"multimodal_parts": [
{
"type": "image_url",
"url": "https://example.com/image.png"
}
],
"top_k": 8,
"top_n": 10,
"recall_method": "mixed",
"recall_ratio": 0.8,
"messages": [
{
"role": "user",
"content": "你是谁"
},
{
"role": "assistant",
"content": "我是小智,一个智能助手"
}
]
}
'import requests
url = "https://open.bigmodel.cn/api/zrag/retrieval/retrieve"
payload = {
"multimodal": True,
"knows": [{ "id": "1234567890" }],
"query": "介绍一下小智",
"multimodal_parts": [
{
"type": "image_url",
"url": "https://example.com/image.png"
}
],
"top_k": 8,
"top_n": 10,
"recall_method": "mixed",
"recall_ratio": 0.8,
"messages": [
{
"role": "user",
"content": "你是谁"
},
{
"role": "assistant",
"content": "我是小智,一个智能助手"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
multimodal: true,
knows: [{id: '1234567890'}],
query: '介绍一下小智',
multimodal_parts: [{type: 'image_url', url: 'https://example.com/image.png'}],
top_k: 8,
top_n: 10,
recall_method: 'mixed',
recall_ratio: 0.8,
messages: [{role: 'user', content: '你是谁'}, {role: 'assistant', content: '我是小智,一个智能助手'}]
})
};
fetch('https://open.bigmodel.cn/api/zrag/retrieval/retrieve', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.post("https://open.bigmodel.cn/api/zrag/retrieval/retrieve")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"multimodal\": true,\n \"knows\": [\n {\n \"id\": \"1234567890\"\n }\n ],\n \"query\": \"介绍一下小智\",\n \"multimodal_parts\": [\n {\n \"type\": \"image_url\",\n \"url\": \"https://example.com/image.png\"\n }\n ],\n \"top_k\": 8,\n \"top_n\": 10,\n \"recall_method\": \"mixed\",\n \"recall_ratio\": 0.8,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"你是谁\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"我是小智,一个智能助手\"\n }\n ]\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://open.bigmodel.cn/api/zrag/retrieval/retrieve"
payload := strings.NewReader("{\n \"multimodal\": true,\n \"knows\": [\n {\n \"id\": \"1234567890\"\n }\n ],\n \"query\": \"介绍一下小智\",\n \"multimodal_parts\": [\n {\n \"type\": \"image_url\",\n \"url\": \"https://example.com/image.png\"\n }\n ],\n \"top_k\": 8,\n \"top_n\": 10,\n \"recall_method\": \"mixed\",\n \"recall_ratio\": 0.8,\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"你是谁\"\n },\n {\n \"role\": \"assistant\",\n \"content\": \"我是小智,一个智能助手\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://open.bigmodel.cn/api/zrag/retrieval/retrieve",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'multimodal' => true,
'knows' => [
[
'id' => '1234567890'
]
],
'query' => '介绍一下小智',
'multimodal_parts' => [
[
'type' => 'image_url',
'url' => 'https://example.com/image.png'
]
],
'top_k' => 8,
'top_n' => 10,
'recall_method' => 'mixed',
'recall_ratio' => 0.8,
'messages' => [
[
'role' => 'user',
'content' => '你是谁'
],
[
'role' => 'assistant',
'content' => '我是小智,一个智能助手'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"data": {
"contents": [
{
"id": "<string>",
"know_id": "<string>",
"doc_id": "<string>",
"text": "<string>",
"medias": [
{
"id": "<string>",
"url": "<string>",
"description": "<string>"
}
],
"image_url": {
"url": "<string>"
},
"video_url": {
"url": "<string>"
},
"index": 123,
"score": 123,
"rerank_index": 123,
"rerank_score": 123,
"metadata": {
"doc_type": "<string>",
"doc_name": "<string>",
"doc_url": "<string>",
"index": 123,
"page_index": 123,
"clip_index": 123,
"start_time": 123,
"end_time": 123,
"duration": 123,
"frames": [
"<string>"
]
}
}
],
"rewritten_query": {
"original_query": "<string>",
"multi_queries": [
"<string>"
]
},
"elapsed_ms": 123,
"total_tokens": 123,
"request_id": "<string>"
},
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}Body
application/json
查询的知识库列表
Show child attributes
Show child attributes
是否走多模态路径检索,默认值为true
文本查询内容,与多模态查询内容必须传入其中之一
多模态查询内容,与文本查询内容必须传入其中之一
Show child attributes
Show child attributes
最终召回数量,默认为8
初始召回数量,默认为10
文本检索方式:embedding(向量检索)、keyword(关键词检索)、mixed(混合检索)
Available options:
embedding, keyword, mixed 混合检索中向量检索的权重,取值范围0~1
是否开启重排,默认不开启
是否开启查询重写,可配合messages参数实现多轮对话改写,默认不开启
是否开启扩召,默认不开启
相似度阈值,低于该阈值的切片会被过滤
当前对话消息列表,用于多轮对话改写
Show child attributes
Show child attributes
过滤条件
Show child attributes
Show child attributes
Was this page helpful?
⌘I