MCPcopy Index your code
hub / github.com/simstudioai/sim / sendChunk

Function sendChunk

apps/sim/lib/workflows/streaming/streaming.ts:374–391  ·  view source on GitHub ↗
(
        blockId: string,
        content: string,
        options: { selectedOutputKey?: string; selectedOutputBytes?: number } = {}
      )

Source from the content-addressed store, hash-verified

372 }
373
374 const sendChunk = (
375 blockId: string,
376 content: string,
377 options: { selectedOutputKey?: string; selectedOutputBytes?: number } = {}
378 ) => {
379 const separator = state.processedOutputs.size > 0 ? '\n\n' : ''
380 const chunk = separator + content
381 if (options.selectedOutputKey) {
382 const selectedOutputBytes =
383 options.selectedOutputBytes ?? Buffer.byteLength(chunk, 'utf8')
384 const nextSelectedOutputBytes = state.selectedOutputBytes + selectedOutputBytes
385 assertInlineMaterializationSize(nextSelectedOutputBytes, MAX_INLINE_MATERIALIZATION_BYTES)
386 state.selectedOutputBytes = nextSelectedOutputBytes
387 state.streamedSelectedOutputKeys.add(options.selectedOutputKey)
388 }
389 controller.enqueue(encodeSSE({ blockId, chunk }))
390 state.processedOutputs.add(blockId)
391 }
392
393 /**
394 * Callback for handling streaming execution events.

Callers 2

onStreamCallbackFunction · 0.85
onBlockCompleteCallbackFunction · 0.85

Calls 4

encodeSSEFunction · 0.90
enqueueMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected