MCPcopy Create free account
hub / github.com/TanStack/ai / createRecordingTextAdapter

Function createRecordingTextAdapter

packages/ai/tests/summarize-max-length.test.ts:16–31  ·  view source on GitHub ↗

* Fake text adapter that records the `modelOptions` it is handed and yields a * trivial summary stream. `name` is irrelevant here — the summarize wrapper * keys off its OWN `name` (set via the constructor) to resolve the provider's * max-tokens spelling.

()

Source from the content-addressed store, hash-verified

14 * max-tokens spelling.
15 */
16function createRecordingTextAdapter(): {
17 textAdapter: ChatStreamCapable
18 lastModelOptions: () => Record<string, unknown> | undefined
19} {
20 let recorded: Record<string, unknown> | undefined
21 const textAdapter: ChatStreamCapable = {
22 chatStream(opts: TextOptions<any>): AsyncIterable<StreamChunk> {
23 recorded = opts.modelOptions as Record<string, unknown> | undefined
24 return (async function* () {
25 yield ev.textContent('summary')
26 yield ev.runFinished('stop')
27 })()
28 },
29 }
30 return { textAdapter, lastModelOptions: () => recorded }
31}
32
33describe('ChatStreamSummarizeAdapter — maxLength reaches the wrapped adapter under the native key', () => {
34 it('OpenAI-style adapter receives maxLength as max_output_tokens', async () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected