Open History to see the last commit
1import type {
2 AIAdapter,
3 ChatCompletionOptions,
4 StreamChunk,
5} from '@tanstack/ai'
6import { stubLLM } from './stub-llm'
7
8/**
9 * Stub adapter for testing without using real LLM tokens
10 * Returns canned tool call responses based on user input
11 */
12export function stubAdapter(): AIAdapter<
13 string,
14 any,
15 any,
16 any,
17 any,
18 any,
19 any,
20 any,
21 any,
22 any
23> {
24 return {
25 name: 'stub',
26 async *chatStream(
27 options: ChatCompletionOptions,
28 ): AsyncIterable<StreamChunk> {
29 // Use stub LLM instead of real API
30 yield* stubLLM(options.messages)
31 },
32 } as any
33}