(provider: Provider, model?: string)
| 135 | } |
| 136 | |
| 137 | function adapterFor(provider: Provider, model?: string): AnyTextAdapter { |
| 138 | const baseModel = stripModelSuffix(model) |
| 139 | switch (provider) { |
| 140 | case 'openai': |
| 141 | return openaiText((baseModel || 'gpt-5.2') as 'gpt-5.2') |
| 142 | case 'openai-chat': |
| 143 | // Same model surface as the Responses adapter, but talks to |
| 144 | // `/v1/chat/completions`. Useful for side-by-side comparison of |
| 145 | // streaming structured output across the two OpenAI wire formats. |
| 146 | return openaiChatCompletions((baseModel || 'gpt-4o') as 'gpt-4o') |
| 147 | case 'anthropic': |
| 148 | // Claude 4.5+ supports native combined tools + schema-constrained |
| 149 | // streaming (#605) via `output_config.format` on the beta Messages |
| 150 | // endpoint. Earlier models fall back to the forced-tool-use |
| 151 | // workaround in `structuredOutput` (no real streaming). |
| 152 | return anthropicText( |
| 153 | (baseModel || 'claude-sonnet-4-5') as 'claude-sonnet-4-5', |
| 154 | ) |
| 155 | case 'gemini': |
| 156 | // Gemini 3.x supports native combined tools + schema-constrained |
| 157 | // streaming (#605) via `config.responseSchema` + |
| 158 | // `responseMimeType: 'application/json'` on a single |
| 159 | // `generateContentStream` call. Gemini 2.x is documented as brittle |
| 160 | // for the combination and falls back to the engine's legacy |
| 161 | // finalization path. |
| 162 | // |
| 163 | // Default is `gemini-3.5-flash`: the newest *stable* (non-preview) |
| 164 | // 3.x id, matching the dropdown's first entry. The previous default |
| 165 | // (`gemini-3-pro-preview`) was retired by Google and now 404s. |
| 166 | return geminiText((baseModel || 'gemini-3.5-flash') as 'gemini-3.5-flash') |
| 167 | case 'grok': |
| 168 | return grokText((model || 'grok-build-0.1') as 'grok-build-0.1') |
| 169 | case 'groq': |
| 170 | return groqText( |
| 171 | (model || |
| 172 | 'meta-llama/llama-4-maverick-17b-128e-instruct') as 'meta-llama/llama-4-maverick-17b-128e-instruct', |
| 173 | ) |
| 174 | case 'openrouter': |
| 175 | return openRouterText( |
| 176 | (model || 'anthropic/claude-opus-4.6') as 'anthropic/claude-opus-4.6', |
| 177 | ) |
| 178 | case 'openrouter-responses': |
| 179 | // OpenRouter Responses (beta) endpoint — same model surface as the |
| 180 | // chat-completions adapter, but routes through `/v1/responses`. This |
| 181 | // is what exercises `OpenRouterResponsesTextAdapter.structuredOutputStream`. |
| 182 | return openRouterResponsesText( |
| 183 | (model || 'anthropic/claude-opus-4.6') as 'anthropic/claude-opus-4.6', |
| 184 | ) |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | // Per-provider modelOptions to opt into reasoning surfacing. Without these, |
| 189 | // reasoning models reason silently and the UI never sees REASONING_* events. |
no test coverage detected