MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / extractTextFromChunk

Function extractTextFromChunk

packages/components/src/utils.ts:301–312  ·  view source on GitHub ↗
(response: AIMessageChunk)

Source from the content-addressed store, hash-verified

299 * content blocks that reasoning models may return.
300 */
301const 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

Callers 2

invokeMethod · 0.85
_transformMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected