(response: AIMessageChunk)
| 299 | * content blocks that reasoning models may return. |
| 300 | */ |
| 301 | const extractTextFromChunk = (response: AIMessageChunk): string => { |
| 302 | if (typeof response.content === 'string') { |
| 303 | return response.content |
| 304 | } |
| 305 | if (Array.isArray(response.content)) { |
| 306 | return response.content |
| 307 | .filter((block: any) => block.type === 'text' || block.type === 'text_delta') |
| 308 | .map((block: any) => block.text ?? '') |
| 309 | .join('') |
| 310 | } |
| 311 | return '' |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Creates a streaming-compatible output parser that extracts text content from |
no outgoing calls
no test coverage detected