知识库问答对话
POST
https://api.listenai.com/v1/knowledge-bases/{{index_id}}/chat/completions
请求参数
Header 参数
Content-Type
string
可选
示例值:
application/json
Authorization
string
可选
示例值:
Bearer {{token}}
Body 参数application/json
messages
array [object {2}]
会话和提问
role
string
角色
content
string
文本内容
doc_ids
array[string]
文档ID数组
prompt_id
string
对话prompt
model
string
模型
limit
number
数量
threshold
number
阈值
>= 0<= 1
temperature
核采样阈值
stream
boolean
是否支持流式
示例
{
"messages": [
{
"role": "string",
"content": "string"
}
],
"doc_ids": [
"string"
],
"prompt_id": "string",
"model": "string",
"limit": 0,
"threshold": 0,
"temperature": null,
"stream": true
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location -g --request POST 'https://api.listenai.com/v1/knowledge-bases/{{index_id}}/chat/completions' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data-raw ''
返回响应
🟢200成功
application/json
Body
choices
array [object {3}]
必需
finish_reason
null
可选
index
integer
可选
message
object
可选
created
integer
必需
id
string
必需
object
string
必需
usage
object
必需
completion_tokens
integer
必需
prompt_tokens
integer
必需
question_tokens
integer
必需
total_tokens
integer
必需
示例
{
"choices": [
{
"finish_reason": null,
"index": 0,
"message": {
"content": "您可以使用遥控器或通过App内的语音控制页面来开启和关闭空调。如果您需要输入新的指令,需要重新唤醒空调。",
"role": "assistant"
}
}
],
"created": 1692107109,
"id": "cht000bcd39@dx189f97169419a4b540",
"object": "chat.completion",
"usage": {
"completion_tokens": 72,
"prompt_tokens": 943,
"question_tokens": 943,
"total_tokens": 1015
}
}
修改于 2023-09-27 07:21:59