Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

features.ts

187 lines4.8 KB

1import type { Feature, Provider } from '@/lib/types'
2import { getGuitars, compareGuitars, addToCart } from '@/lib/tools'
3​
4interface FeatureConfig {
5 tools: Array<any>
6 modelOptions: Record<string, any>
7 modelOverrides?: Partial<Record<Provider, string>>
8 dedicatedRoute?: string
9 /**
10 * Optional system prompt override. Defaults (in `api.chat.ts`) to the
11 * guitar-store assistant prompt that covers most features; only set this
12 * when the feature genuinely needs a different persona (e.g. the
13 * `multi-turn-structured` chef recipe-builder).
14 */
15 systemPrompt?: string
17​
18/**
19 * The byteplus model every structured-output feature overrides to.
20 *
21 * The default e2e chat model (`seed-2-0-lite-260428`, in `providers.ts`)
22 * rejects both `response_format: json_schema` and `json_object` — live-probed,
23 * and the adapter throws rather than silently degrading, so any feature that
24 * asks for a schema has to move off it. `seed-2-0-lite-260228` is the nearest
25 * sibling that accepts json_schema *and* honours it (glm-4-7 accepts it and
26 * returns prose, so acceptance alone isn't enough), and it keeps image input,
27 * which `multimodal-structured` needs.
28 */
29const BYTEPLUS_STRUCTURED_MODEL = 'seed-2-0-lite-260228'
30​
31export const featureConfigs: Record<Feature, FeatureConfig> = {
32 chat: {
33 tools: [],
34 modelOptions: {},
35 },
36 'one-shot-text': {
37 tools: [],
38 modelOptions: {},
39 },
40 reasoning: {
41 tools: [],
42 modelOptions: { reasoning: { effort: 'high' } },
43 modelOverrides: {
44 openai: 'o3',
45 anthropic: 'claude-sonnet-4-5',
46 mistral: 'magistral-medium-latest',
47 },
48 },
49 'multi-turn': {
50 tools: [],
51 modelOptions: {},
52 },
53 'tool-calling': {
54 tools: [getGuitars],
55 modelOptions: {},
56 },
57 'parallel-tool-calls': {
58 tools: [getGuitars, compareGuitars],
59 modelOptions: {},
60 },
61 'tool-approval': {
62 tools: [addToCart],
63 modelOptions: {},
64 },
65 'text-tool-text': {
66 tools: [getGuitars],
67 modelOptions: {},
68 },
69 'structured-output': {
70 tools: [],
71 modelOptions: {},
72 modelOverrides: { byteplus: BYTEPLUS_STRUCTURED_MODEL },
73 },
74 'structured-output-stream': {
75 tools: [],
76 modelOptions: {},
77 modelOverrides: { byteplus: BYTEPLUS_STRUCTURED_MODEL },
78 },
79 'multi-turn-structured': {
80 tools: [],
81 modelOptions: {},
82 modelOverrides: { byteplus: BYTEPLUS_STRUCTURED_MODEL },
83 systemPrompt:
84 'You are a chef assistant that always responds with a single recipe matching the provided JSON schema. When the user asks for modifications, produce a new recipe in the same shape that reflects the change. Stay terse — short titles, short steps.',
85 },
86 'agentic-structured': {
87 tools: [getGuitars],
88 modelOptions: {},
89 modelOverrides: { byteplus: BYTEPLUS_STRUCTURED_MODEL },
90 },
91 // Pins #605 native-combined-mode: `outputSchema` + `tools` + `stream: true`
92 // in a single chat call. Default openai (gpt-4o) and anthropic
93 // (claude-sonnet-4-5) are already in their combined-mode-capable sets;
94 // gemini, vertex, and grok need overrides to gated models so the engine
95 // takes the native path instead of the legacy
96 // `runStructuredFinalization` round-trip.
97 'agentic-structured-stream': {
98 tools: [getGuitars],
99 modelOptions: {},
100 modelOverrides: {
101 gemini: 'gemini-3-flash-preview',
102 vertex: 'gemini-3-flash-preview',
103 grok: 'grok-build-0.1',
104 'vertex-grok': 'grok-4.3',
105 // Reports combined tools+schema support, so the engine takes the
106 // native path here too.
107 byteplus: BYTEPLUS_STRUCTURED_MODEL,
108 },
109 },
110 'multimodal-image': {
111 tools: [],
112 modelOptions: {},
113 },
114 'multimodal-document': {
115 tools: [],
116 modelOptions: {},
117 },
118 'multimodal-structured': {
119 tools: [],
120 modelOptions: {},
121 modelOverrides: { byteplus: BYTEPLUS_STRUCTURED_MODEL },
122 },
123 summarize: {
124 tools: [],
125 modelOptions: {},
126 },
127 'summarize-stream': {
128 tools: [],
129 modelOptions: {},
130 },
131 embedding: {
132 tools: [],
133 modelOptions: {},
134 },
135 'image-gen': {
136 tools: [],
137 modelOptions: {},
138 },
139 'image-to-image': {
140 tools: [],
141 modelOptions: {},
142 },
143 'audio-gen': {
144 tools: [],
145 modelOptions: {},
146 },
147 'sound-effects': {
148 tools: [],
149 modelOptions: {},
150 },
151 tts: {
152 tools: [],
153 modelOptions: {},
154 },
155 'voice-design': {
156 tools: [],
157 modelOptions: {},
158 },
159 transcription: {
160 tools: [],
161 modelOptions: {},
162 },
163 'transcription-diarization': {
164 tools: [],
165 modelOptions: {},
166 },
167 'video-gen': {
168 tools: [],
169 modelOptions: {},
170 },
171 'image-to-video': {
172 tools: [],
173 modelOptions: {},
174 },
175 'interactions-video': {
176 tools: [],
177 modelOptions: {},
178 },
179 'stateful-interactions': {
180 tools: [],
181 modelOptions: {},
182 },
183 'video-understanding': {
184 tools: [],
185 modelOptions: {},
186 },