MCPcopy
hub / github.com/TanStack/ai / ChunkStrategy

Interface ChunkStrategy

packages/ai/src/activities/chat/stream/types.ts:38–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36 * Strategy for determining when to emit text updates
37 */
38export interface ChunkStrategy {
39 /**
40 * Called for each text chunk received
41 * @param chunk - The new chunk of text (delta)
42 * @param accumulated - All text accumulated so far
43 * @returns true if an update should be emitted now
44 */
45 shouldEmit: (chunk: string, accumulated: string) => boolean
46
47 /**
48 * Optional: Reset strategy state (called when streaming starts)
49 */
50 reset?: () => void
51}
52
53/**
54 * Per-message streaming state.

Callers

nothing calls this directly

Implementers 5

ImmediateStrategypackages/ai/src/activities/chat/stream
PunctuationStrategypackages/ai/src/activities/chat/stream
BatchStrategypackages/ai/src/activities/chat/stream
WordBoundaryStrategypackages/ai/src/activities/chat/stream
CompositeStrategypackages/ai/src/activities/chat/stream

Calls

no outgoing calls

Tested by

no test coverage detected