MCPcopy Index your code
hub / github.com/TanStack/ai / buildStructuredStream

Function buildStructuredStream

packages/ai/tests/structured-output-middleware.test.ts:124–137  ·  view source on GitHub ↗

Build the chunk sequence the mock structured-output stream emits. * Uses typed `ev.*` factories (RunStartedEvent, TextMessage*Event, * RunFinishedEvent) and the typed `structured*Event` helpers above. * No `as X` casts.

(
  value: Person,
  usage?: RunFinishedEvent['usage'],
)

Source from the content-addressed store, hash-verified

122 * RunFinishedEvent) and the typed `structured*Event` helpers above.
123 * No `as X` casts. */
124function buildStructuredStream(
125 value: Person,
126 usage?: RunFinishedEvent['usage'],
127): Array<StreamChunk> {
128 return [
129 ev.runStarted('mock-run', 'mock-thread'),
130 structuredStartEvent('mock-msg'),
131 ev.textStart('mock-msg'),
132 ev.textContent(JSON.stringify(value), 'mock-msg'),
133 ev.textEnd('mock-msg'),
134 structuredCompleteEvent(value),
135 ev.runFinished('stop', 'mock-run', usage, 'mock-thread'),
136 ]
137}
138
139function makeAdapter(opts: {
140 agentIterations?: Array<Array<StreamChunk>>

Callers 1

makeAdapterFunction · 0.70

Calls 2

structuredStartEventFunction · 0.85
structuredCompleteEventFunction · 0.85

Tested by

no test coverage detected