SseChat - Question answering API

Updated at:

Provides question answering over SSE.

Try it out

You can call this operation in OpenAPI Explorer without calculating a signature. After a successful call, OpenAPI Explorer can automatically generate SDK code examples.

Try it out

Authorization information

The following table describes the authorization information for this API operation. You can use this information in the Action element of a RAM policy statement to grant a RAM user or RAM role permission to call the operation. The columns are described as follows:

  • Action: a specific permission.

  • Access level: the access level of an action. Valid values: Write, Read, and List.

  • Resource type: the types of resources for which the action supports authorization:

    • Required resource types are marked with an asterisk (*).
    • Actions that do not support resource-level authorization use All resources.
  • Condition key: a condition key defined by the cloud service.

  • Dependent action: an additional permission required to perform the action. The caller must also have permission to perform the dependent action.

ActionAccess levelResource typeCondition keyDependent action
bailianchatbot:SseChatnone
*All resources
*
    None
None

Request syntax

POST /sse/bailian/chat HTTP/1.1

Request parameters

NameTypeRequiredDescriptionExample
AppIdstringYes

The application ID. Create and query applications in the console. Only one ID can be specified.

chatbot-cn-dDmF3jcdVf
UtterancestringYes

The input from the chatbot visitor.

What can you do?
SessionIdstringNo

The session ID, used to identify a visitor's session and maintain context.

15e04f27-acd7-489d-872f-1d68f7535e33
SenderIdstringNo

The visitor ID, used to identify the user in the current session.

uid129312098593
SenderNickstringNo

The visitor nickname.

Zhang San
VendorParamstringNo

A JSON-formatted set of user-defined parameters (pass-through parameters) that can be passed to conversation engines. Examples:

  • Single value: {"phone":123456789}

  • Array: {"name":["a","b","c"]}

  • Document labels: {"docLabels":"标签 1,标签 2"}

{"docLabels":"标签1,标签2"}
CommandstringNo

The command for this request.

Currently supported values:

  • TIMEOUT: triggers the timeout response in Dialog Studio.
  • GUIDEPOST: triggers the asynchronous service of a dialog flow. For details, see the asynchronous service user guide.
TIMEOUT
WorkspaceIdstringYes

The unique ID of the Model Studio workspace: Obtain workspaceId

llm-g7jspxljq8k909h3

Response parameters

NameTypeDescriptionExample
object

Schema of Response

RequestIdstring

The request ID.

30D68C4C-4512-58A7-A328-568015B39A02
Dataany

The returned data.

See the supplementary response parameter descriptions.
Successboolean

Indicates whether the request succeeded.

True
Messagestring

The error description.

success
Codestring

The result code.

200

Example descriptions

Sample response

{
    "MessageBody": {
        "DirectMessageBody": {
            "ContentType": "RICH_TEXT",
            "Ext": {},
            "HitSystemAskConfig": "GPTQA_MODEL",
            // 大模型输出的答案:把 SentenceList 列表每一个 content 为一个段落。
            "SentenceList": [
                {
                    "Content": "我作为一名人工智能助手,"
                }
            ]
        },
        "Type": "Direct"
    },
    "MessageId": "d8720210-9588-4b49-b412-09648621a073",
    "SequenceId": "f186e72492214631a6a150b2288d269f",
    "SessionId": "cidu1dmqF8iUdz2gNonzzZAhsWsocstnJqThr+wp430evc=",
    "Source": "SYSTEM_ASK_CONFIG",
    "StreamEnd": false
}

Additional sample responses

Source=TASK_DRIVEN_DIALOGUE

{
    "MessageBody":{
        "Commands":{},
        "DirectMessageBody":{
            "ContentType":"PLAIN_TEXT",
            "Ext":{
                "EXTERNAL_FLAGS":{}
            },
            "SentenceList":[
                {
                    "Content":"北京市晴,气温 8 摄氏度,东风 ≤3 级"
                }
            ]
        },
        "Type":"Direct"
    },
    "MessageId":"7a2cdb51-af56-4ac9-9c6d-108905695ac9",
    "SequenceId":"4861074fe523498ba3f397e876b60105",
    "SessionId":"f3d7e960933411ee96144bea43fe4df3",
    "Source":"TASK_DRIVEN_DIALOGUE",
    "StreamEnd":true
}

Source=NON_STRUCTURAL_KNOWLEDGE

{
    "MessageBody":{
        "DirectMessageBody":{
            "AnswerReference":{
                "ItemList":[
                    {
                        "Content":"你好",
                        "ContentType":"RICH_TEXT",
                        "DataSource":"FAQ_DIRECT",
                        "Number":1,
                        "ReferenceExt":{
                            "DocName":"FAQ 知识库"
                        },
                        "Title":"你好"
                    }
                ]
            },
            "ContentType":"RICH_TEXT",
            "SentenceList":[
                {
                    "Content":"你好",
                    "ReferNumber":1
                }
            ]
        },
        "Type":"Direct"
    },
    "MessageId":"808a9cfb-2cec-4230-aad1-66c28df6040e",
    "SequenceId":"32a052f098c14769b8b81ac202f38d01",
    "SessionId":"595fa8a0940611eeb59a155f6621f5d6",
    "Source":"NON_STRUCTURAL_KNOWLEDGE",
    "StreamEnd":true
}

Source=SYSTEM_ASK_CONFIG

{
    "MessageBody":{
        "DirectMessageBody":{
            "ContentType":"PLAIN_TEXT",
            "HitSystemAskConfig":"NO_ANSWER",
            "SentenceList":[
                {
                    "Content":"我还没有学会这个问题,已经记录会尽快学习为您解答,请尝试询问我其他问题"
                }
            ]
        },
        "Type":"Direct"
    },
    "MessageId":"f13833e7-9ca4-4a5b-8878-f5cc8a0a327c",
    "SequenceId":"245c39ce1f11406bb3cf60b4d017dff0",
    "SessionId":"6e7c44a0940111ee91e69d173591e2de",
    "Source":"SYSTEM_ASK_CONFIG",
    "StreamEnd":true
}

Examples

Sample success response

JSON format

{
  "RequestId": "30D68C4C-4512-58A7-A328-568015B39A02",
  "Data": "详见返回参数补充说明",
  "Success": true,
  "Message": "success",
  "Code": 200
}

Error codes

For more error codes, see Error Center.