流式问答
知识库问答(stream)
知识库问答对话, text/event-stream 流式返回回答内容。
如果请求参数 model 设置为
deepseek-lite
或deepseek-pro
,流式返回数据中result.response
会包含<think></think>
和<response></response>
标签。
shell
curl --location --request POST 'https://openapi.youdao.com/q_anything/api/chat_stream' \
--header 'Authorization: {{apikey}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"question": "你是谁",
"kbIds": ["KB248e8e079642491383596f63c2ab069a_240430"],
"prompt": "",
"history": [{ "question": "你好", "response": "嗯,你好。" }],
"model": "QAnything 4o mini",
"maxToken": "1024",
"hybridSearch": "false",
"networking": "true",
"sourceNeeded": "true"
}'
json
{
"question": "你是谁", // 提问内容,长度不超过200字符(必填)
"kbIds": ["KB248e8e079642491383596f63c2ab069a_240430"], // 知识库Id,json数组,可以选择多个知识库问答(必填)
"prompt": "", // 请求prompt,不超过500字符
"history": [{ "question": "你好", "response": "嗯,你好。" }], // 对话历史,history最多支持2轮,如果为空填写"history":[](必填)
"model": "QAnything 4o mini", // 模型选择,取值:QAnything 4o mini,QAnything 4o,deepseek-pro,deepseek-lite,deepseek-chat
"maxToken": 1024, // 最大回复token限制,QAnything 4o mini范围:512-1024 默认512;QAnything 4o:1024-4096默认1024;QAnything 16k:1024-4096默认1024
"hybridSearch": false, // 是否开启混合检索,true或false,默认false
"networking": true, // 是否开启联网检索,true或false,默认false
"sourceNeeded": true // 是否返回信息来源,true或false,默认true
}
json
中间过程只有result字段的response有值, 其余字段的信息在最终分片返回。
{
"event": "data",
{
"errorCode": 0, // 错误码
"msg": "SUCCESS", // 描述
"requestId": "38e4e659-13a7-45ea-b8c5-484979348b43", // 请求id
"result": {
"question": "你是谁", // 本轮提问
"response": "我是QAnything。", // 本轮回答
"history": [ // 历史问答列表
{
"question": "你好", // 历史提问
"response": "嗯,你好。", // 历史回答
}
],
"source": [ // 信息来源
{
"fileId": "a4b17c078f3a4ed489391daf51ee0b06", // 文档id
"fileName": "QAnything_QA_模板.xlsx", // 文档名称
"content": "问题: 你是谁 & 答案: 我是QAnything", // 来源的原文内容
"score": "1.3776044845581055", // 可信度
}
],
"aiPointCost": 2031 //AI积分消耗 仅在最终分片返回
}
}
}
Agents 问答(stream)
Agents 问答对话, text/event-stream 流式返回回答内容
如果对应Agent的
model
参数设置为deepseek-lite
或deepseek-pro
(可以通过“查询Agent详情”接口查询Agent信息),流式返回数据中result.response
会包含<think></think>
和<response></response>
标签。
shell
curl --location --request POST 'https://openapi.youdao.com/q_anything/api/bot/chat_stream' \
--header 'Authorization: {{apikey}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"uuid": "C1BDCFC4F33747E7",
"question": "你是谁",
"sourceNeeded": "true",
"history": [{ "question": "你好", "response": "嗯,你好。" }]
}'
json
{
"uuid": "C1BDCFC4F33747E7", // Agent uuid(必填)
"question": "你是谁", // 提问内容,长度不超过200字符(必填)
"sourceNeeded": true, // 是否返回信息来源,true或false,默认true
"history": [{ "question": "你好", "response": "嗯,你好。" }] // 对话历史,history最多支持2轮,如果为空填写"history":[](必填)
}
json
中间过程只有result字段的response有值, 其余字段的信息在最终分片返回。
{
"event": "data",
{
"errorCode": 0, // 错误码
"msg": "SUCCESS", // 描述
"requestId": "38e4e659-13a7-45ea-b8c5-484979348b43", // 请求id
"result": {
"question": "你是谁", // 本轮提问
"response": "我是QAnything。", // 本轮回答
"history": [ // 历史问答列表
{
"question": "你好", // 历史提问
"response": "嗯,你好。", // 历史回答
}
],
"source": [ // 信息来源
{
"fileId": "a4b17c078f3a4ed489391daf51ee0b06", // 文档id
"fileName": "QAnything_QA_模板.xlsx", // 文档名称
"content": "问题: 你是谁 & 答案: 我是QAnything", // 来源的原文内容
"score": "1.3776044845581055", // 可信度
}
],
"aiPointCost": 2031 //AI积分消耗 仅在最终分片返回
}
}
}