Files
ZNJJ-api-server/docs/chat-stream-mode.md

1.3 KiB

/chat 流式响应模式说明

接口地址

POST http://localhost:8000/chat?stream=true

请求参数

参数 类型 必填 说明
sessionId string 会话 ID
timeStamp string 时间戳
text string 用户输入文本
stream bool 设为 true 启用流式响应

SSE 事件类型

事件类型 说明 数据格式
stage_code 阶段状态码 {"nextStageCode": "0000", "nextStage": "结束通话"}
text_delta 流式文本片段 {"text": "您好..."}
done 流式结束 {"status": "completed"}
error 错误信息 {"msg": "错误描述", "code": "500"}

状态码映射

状态码 含义
0000 结束通话
0001 转接人工
0002 语义无法识别转接人工
0003 有人伤转接人工
1001 未准备好通话
1002 通话中
2000 进入单车拍照
... ...

示例

请求

python examples/stream_chat.py session-001 "发生了交通事故"

响应

Status: 200
--------------------------------------------------
[stage_code] {"nextStageCode": "1002", "nextStage": "通话中"}
[text_delta] {"text": "您好,请问发生了什么情况?"}
[done] {"status": "completed"}