大模型對話介面主要用於直接與大語言模型進行對話。可以通過設定prompt參數指定問題或對話內容,支援不同的大語言模型,並可以設定是否需要綠網處理等選項。
前提條件
介面資訊
要求方法 | 請求協議 | 請求資料格式 |
POST | HTTP | JSON |
請求URL
{host}/v3/openapi/apps/[app_group_identity]/actions/knowledge-llm{host}:調用服務的地址,支援通過公網和VPC兩種方式調用API服務,可參見擷取服務調用地址。{app_group_identity}:應用程式名稱,需要登入OpenSearch-LLM智能問答版控制台,在執行個體管理中查看對應執行個體的應用程式名稱。
請求參數
參數 | 類型 | 描述 | 樣本值 |
question | String | 使用者問題 | what is OpenSearch |
type | String | 問題類型 | text |
content | Array | 內容 | ["OpenSearch","問天引擎"] |
options | Json | 選項 | |
stream | Boolean | 是否流式返回 | false |
prompt | String | prompt內容 | |
model | String | 可選的LLM模型 新加坡地區:
| "qwen-turbo" |
csi_level | String | 大模型產生的內容是否需要經過綠網處理。
| none |
請求體樣本:
1、根據文檔內容進行總結
{
"question" : "使用者問題",
"type" : "text",
"content" : ["候選的內容1","候選內容2"],
"options" : {
"stream" : false, #是否流式返回,預設為false
},
"model": "Qwen",
"csi_level" : "none" # 大模型產生的內容是否需要經過綠網處理。none: 表示不需要綠網處理;loose:不攔截疑似有問題的內容
}2、直接指定prompt回答
{
"prompt": "prompt內容",
"model": "Qwen",
"options" : {
"stream" : false, #是否流式返回,預設為false
},
"csi_level" : "none" # 大模型產生的內容是否需要經過綠網處理。none: 表示不需要綠網處理;loose:不攔截疑似有問題的內容
}一旦prompt內容被設定,那麼question和content參數將會被忽視,該參數的內容會被直接作為大模型的prompt
返回參數
參數 | 類型 | 描述 | 樣本值 |
request_id | String | 請求ID | abc123-ABC |
latency | Float | 延遲 | 10.0 |
result | Json | 結果 | |
data | Array | 返回資料集 | |
answer | String | 答案 | answer text |
type | String | 答案類型 | text |
errors | Array | 錯誤資訊集 | |
code | String | 錯誤碼 | 1001 |
message | String | 錯誤資訊 | APP is not found |
響應體樣本:
{
"request_id" : "",
"latency" : 10.0, #單位s
"result" : {
"data": [
{
"answer" : "answer text",
"type" : "text"
]
}
]
},
"errors" : [
{
"code" : "如果有錯誤,這裡填錯誤碼",
"message" : "如果有錯誤,這裡填錯誤資訊"
}
]
}