(output: OpenAI.Responses.ResponseOutputItem[])
| 196 | * Extracts plain text from Responses API output items. |
| 197 | */ |
| 198 | export function extractResponseText(output: OpenAI.Responses.ResponseOutputItem[]): string { |
| 199 | if (!Array.isArray(output)) { |
| 200 | return '' |
| 201 | } |
| 202 | |
| 203 | const textParts: string[] = [] |
| 204 | for (const item of output) { |
| 205 | if (item?.type !== 'message') { |
| 206 | continue |
| 207 | } |
| 208 | |
| 209 | const text = extractTextFromMessageItem(item) |
| 210 | if (text) { |
| 211 | textParts.push(text) |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | return textParts.join('') |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Extracts reasoning summary text from Responses API output items. Reasoning |
no test coverage detected