LSPlatform
  1. 知识库
LSPlatform
  • 【在线调试-使用说明】
  • 大模型接口
    • 标准API
      • 模型对话调用(Completions)
      • 向量计算调用(Embedding)
      • 决策调用(Makes)
    • 提示工程模板
      • Prompt渲染
    • 知识库
      • 创建知识库
        POST
      • 添加文档
        POST
      • 文档分片预览
        POST
      • 知识库问答对话
        POST
      • 获取知识库列表
        GET
      • 获取文档列表
        GET
      • 获取文档详情
        GET
      • 删除文档
        DELETE
      • 删除知识库
        DELETE
      • 知识库文本查询
        GET
      • 知识点溯源查询
        POST
  1. 知识库

知识库问答对话

POST
/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 
角色
可选
可取值: user,assistant ;其中user表示用户的提问,assistant表示AI的回复 ; 若当前message为messages数组的最后一个元素,role的值需为字符串'user'
content
string 
文本内容
可选
该角色的对话内容
doc_ids
array[string]
文档ID数组
可选
prompt_id
string 
对话prompt
可选
model
string 
模型
可选
可取值:spark-general-1.5: 基础模型v1.5版本;spark-general-2.0: 基础模型v2.0版本;
limit
number 
数量
可选
5
threshold
number 
阈值
可选
用于根据知识检索的分数过滤
>= 0<= 1
temperature
核采样阈值
可选
stream
boolean 
是否支持流式
可选
false
示例
{
  "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 '/v1/knowledge-bases/{{index_id}}/chat/completions' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "messages": [
        {
            "role": "string",
            "content": "string"
        }
    ],
    "doc_ids": [
        "string"
    ],
    "prompt_id": "string",
    "model": "string",
    "limit": 0,
    "threshold": 0,
    "temperature": null,
    "stream": true
}'

返回响应

🟢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
上一页
文档分片预览
下一页
获取知识库列表
Built with