The ordered ``/responses`` event objects the runtime's reducer expects.
(text: str, resp_id: str = "resp_stub_1")
| 84 | |
| 85 | |
| 86 | def responses_events(text: str, resp_id: str = "resp_stub_1") -> list[dict]: |
| 87 | """The ordered ``/responses`` event objects the runtime's reducer expects.""" |
| 88 | return [ |
| 89 | { |
| 90 | "type": "response.created", |
| 91 | "response": { |
| 92 | "id": resp_id, |
| 93 | "object": "response", |
| 94 | "status": "in_progress", |
| 95 | "output": [], |
| 96 | }, |
| 97 | }, |
| 98 | { |
| 99 | "type": "response.output_item.added", |
| 100 | "output_index": 0, |
| 101 | "item": {"id": "msg_1", "type": "message", "role": "assistant", "content": []}, |
| 102 | }, |
| 103 | { |
| 104 | "type": "response.content_part.added", |
| 105 | "output_index": 0, |
| 106 | "content_index": 0, |
| 107 | "part": {"type": "output_text", "text": ""}, |
| 108 | }, |
| 109 | { |
| 110 | "type": "response.output_text.delta", |
| 111 | "output_index": 0, |
| 112 | "content_index": 0, |
| 113 | "delta": text, |
| 114 | }, |
| 115 | { |
| 116 | "type": "response.output_text.done", |
| 117 | "output_index": 0, |
| 118 | "content_index": 0, |
| 119 | "text": text, |
| 120 | }, |
| 121 | { |
| 122 | "type": "response.completed", |
| 123 | "response": { |
| 124 | "id": resp_id, |
| 125 | "object": "response", |
| 126 | "status": "completed", |
| 127 | "output": [ |
| 128 | { |
| 129 | "id": "msg_1", |
| 130 | "type": "message", |
| 131 | "role": "assistant", |
| 132 | "content": [{"type": "output_text", "text": text}], |
| 133 | } |
| 134 | ], |
| 135 | "usage": {"input_tokens": 5, "output_tokens": 7, "total_tokens": 12}, |
| 136 | }, |
| 137 | }, |
| 138 | ] |
| 139 | |
| 140 | |
| 141 | def build_non_inference_response( |
no outgoing calls
searching dependent graphs…