fix(qa): stream mock response text deltas · openclaw/openclaw@2966486
vincentkoc
·
2026-05-18
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -27,22 +27,37 @@ function writeJson(res, status, body) {
|
27 | 27 | } |
28 | 28 | |
29 | 29 | function responseEvents(text) { |
| 30 | +const itemId = "msg_e2e_1"; |
30 | 31 | return [ |
31 | 32 | { |
32 | 33 | type: "response.output_item.added", |
33 | 34 | item: { |
34 | 35 | type: "message", |
35 | | -id: "msg_e2e_1", |
| 36 | +id: itemId, |
36 | 37 | role: "assistant", |
37 | 38 | content: [], |
38 | 39 | status: "in_progress", |
39 | 40 | }, |
40 | 41 | }, |
| 42 | +{ |
| 43 | +type: "response.output_text.delta", |
| 44 | +item_id: itemId, |
| 45 | +output_index: 0, |
| 46 | +content_index: 0, |
| 47 | +delta: text, |
| 48 | +}, |
| 49 | +{ |
| 50 | +type: "response.output_text.done", |
| 51 | +item_id: itemId, |
| 52 | +output_index: 0, |
| 53 | +content_index: 0, |
| 54 | + text, |
| 55 | +}, |
41 | 56 | { |
42 | 57 | type: "response.output_item.done", |
43 | 58 | item: { |
44 | 59 | type: "message", |
45 | | -id: "msg_e2e_1", |
| 60 | +id: itemId, |
46 | 61 | role: "assistant", |
47 | 62 | status: "completed", |
48 | 63 | content: [{ type: "output_text", text, annotations: [] }], |
@@ -51,7 +66,17 @@ function responseEvents(text) {
|
51 | 66 | { |
52 | 67 | type: "response.completed", |
53 | 68 | response: { |
| 69 | +id: "resp_e2e", |
54 | 70 | status: "completed", |
| 71 | +output: [ |
| 72 | +{ |
| 73 | +type: "message", |
| 74 | +id: itemId, |
| 75 | +role: "assistant", |
| 76 | +status: "completed", |
| 77 | +content: [{ type: "output_text", text, annotations: [] }], |
| 78 | +}, |
| 79 | +], |
55 | 80 | usage: { |
56 | 81 | input_tokens: 11, |
57 | 82 | output_tokens: 7, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。