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

features.ts

172 lines4.5 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 and grok need overrides to gated models so the engine takes the
95 // native path instead of the legacy `runStructuredFinalization` round-trip.
96 'agentic-structured-stream': {
97 tools: [getGuitars],
98 modelOptions: {},
99 modelOverrides: {
100 gemini: 'gemini-3-flash-preview',
101 grok: 'grok-build-0.1',
102 // Reports combined tools+schema support, so the engine takes the
103 // native path here too.
104 byteplus: BYTEPLUS_STRUCTURED_MODEL,
105 },
106 },
107 'multimodal-image': {
108 tools: [],
109 modelOptions: {},
110 },
111 'multimodal-structured': {
112 tools: [],
113 modelOptions: {},
114 modelOverrides: { byteplus: BYTEPLUS_STRUCTURED_MODEL },
115 },
116 summarize: {
117 tools: [],
118 modelOptions: {},
119 },
120 'summarize-stream': {
121 tools: [],
122 modelOptions: {},
123 },
124 embedding: {
125 tools: [],
126 modelOptions: {},
127 },
128 'image-gen': {
129 tools: [],
130 modelOptions: {},
131 },
132 'image-to-image': {
133 tools: [],
134 modelOptions: {},
135 },
136 'audio-gen': {
137 tools: [],
138 modelOptions: {},
139 },
140 'sound-effects': {
141 tools: [],
142 modelOptions: {},
143 },
144 tts: {
145 tools: [],
146 modelOptions: {},
147 },
148 transcription: {
149 tools: [],
150 modelOptions: {},
151 },
152 'transcription-diarization': {
153 tools: [],
154 modelOptions: {},
155 },
156 'video-gen': {
157 tools: [],
158 modelOptions: {},
159 },
160 'image-to-video': {
161 tools: [],
162 modelOptions: {},
163 },
164 'interactions-video': {
165 tools: [],
166 modelOptions: {},
167 },
168 'stateful-interactions': {
169 tools: [],
170 modelOptions: {},
171 },