为 SSE 示例补充请求标识、连续序号和时间戳,使用多段简短文本模拟流式返回,并同步事件顺序断言。开始事件携带 conversation_id,完成事件携带成功状态。
129 lines
3.6 KiB
JSON
129 lines
3.6 KiB
JSON
{
|
|
"scenarios": [
|
|
{
|
|
"id": "chat-stream",
|
|
"kind": "sse",
|
|
"path": "/chat/stream?trace=demo",
|
|
"headers": {
|
|
"content-type": "application/json",
|
|
"x-test": "sse"
|
|
},
|
|
"body": {
|
|
"message": "你好",
|
|
"messages": [{"role": "user", "content": "你好"}]
|
|
},
|
|
"response": {
|
|
"status": 200,
|
|
"headers": {"content-type": "text/event-stream"},
|
|
"events": [
|
|
{
|
|
"event": "run_started",
|
|
"id": "1",
|
|
"data": {
|
|
"request_id": "a1b2c3d4-1234-4567-89ab-1234567890ab",
|
|
"sequence": 1,
|
|
"timestamp": "2026-10-16T06:00:00.000000+00:00",
|
|
"data": {"conversation_id": null}
|
|
}
|
|
},
|
|
{
|
|
"event": "text_delta",
|
|
"id": "2",
|
|
"data": {
|
|
"request_id": "a1b2c3d4-1234-4567-89ab-1234567890ab",
|
|
"sequence": 2,
|
|
"timestamp": "2026-10-16T06:00:00.100000+00:00",
|
|
"data": {"content": "你好,"}
|
|
}
|
|
},
|
|
{
|
|
"event": "text_delta",
|
|
"id": "3",
|
|
"data": {
|
|
"request_id": "a1b2c3d4-1234-4567-89ab-1234567890ab",
|
|
"sequence": 3,
|
|
"timestamp": "2026-10-16T06:00:00.120000+00:00",
|
|
"data": {"content": "我可以帮助你"}
|
|
}
|
|
},
|
|
{
|
|
"event": "text_delta",
|
|
"id": "4",
|
|
"data": {
|
|
"request_id": "a1b2c3d4-1234-4567-89ab-1234567890ab",
|
|
"sequence": 4,
|
|
"timestamp": "2026-10-16T06:00:00.140000+00:00",
|
|
"data": {"content": "了解工具的用途。\n\n"}
|
|
}
|
|
},
|
|
{
|
|
"event": "text_delta",
|
|
"id": "5",
|
|
"data": {
|
|
"request_id": "a1b2c3d4-1234-4567-89ab-1234567890ab",
|
|
"sequence": 5,
|
|
"timestamp": "2026-10-16T06:00:00.160000+00:00",
|
|
"data": {"content": "请告诉我你想了解的内容。"}
|
|
}
|
|
},
|
|
{
|
|
"event": "run_completed",
|
|
"id": "6",
|
|
"data": {
|
|
"request_id": "a1b2c3d4-1234-4567-89ab-1234567890ab",
|
|
"sequence": 6,
|
|
"timestamp": "2026-10-16T06:00:00.180000+00:00",
|
|
"data": {"status": "success"}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"expect": {
|
|
"status": 200,
|
|
"events": ["run_started", "text_delta", "text_delta", "text_delta", "text_delta", "run_completed"],
|
|
"upstream_path": "/chat/stream?trace=demo"
|
|
}
|
|
},
|
|
{
|
|
"id": "ordinary-post",
|
|
"kind": "post",
|
|
"path": "/api/echo",
|
|
"headers": {"content-type": "application/json"},
|
|
"body": {"message": "普通请求"},
|
|
"response": {
|
|
"status": 200,
|
|
"headers": {"content-type": "application/json"},
|
|
"body": {"ok": true}
|
|
},
|
|
"expect": {
|
|
"status": 200,
|
|
"body": {"ok": true},
|
|
"upstream_path": "/api/echo"
|
|
}
|
|
},
|
|
{
|
|
"id": "text-upload",
|
|
"kind": "file",
|
|
"path": "/upload?source=test",
|
|
"headers": {"x-test": "upload"},
|
|
"file": {
|
|
"field": "file",
|
|
"path": "fixtures/sample.txt",
|
|
"filename": "sample.txt",
|
|
"mime": "text/plain"
|
|
},
|
|
"response": {
|
|
"status": 200,
|
|
"headers": {"content-type": "application/json"},
|
|
"body": {"stored": true}
|
|
},
|
|
"expect": {
|
|
"status": 200,
|
|
"body": {"stored": true},
|
|
"upstream_path": "/upload?source=test",
|
|
"file_forwarded": true
|
|
}
|
|
}
|
|
]
|
|
}
|