Merge pull request #730 from buster-so/hotfix-add-gpt5-to-fallback-chain

add gpt5 to fallback chain on sonnet 4
This commit is contained in:
dal 2025-08-21 09:19:16 -06:00 committed by GitHub
commit df5291be15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 5 deletions

View File

@ -60,6 +60,7 @@ const outputSchema = z.object({
const DEFAULT_CACHE_OPTIONS = {
anthropic: { cacheControl: { type: 'ephemeral', ttl: '1h' } },
openai: { parallelToolCalls: false, reasoningEffort: 'minimal' },
};
/**

View File

@ -82,6 +82,7 @@ const outputSchema = ThinkAndPrepOutputSchema;
const DEFAULT_CACHE_OPTIONS = {
anthropic: { cacheControl: { type: 'ephemeral', ttl: '1h' } },
openai: { parallelToolCalls: false, reasoningEffort: 'minimal' },
};
// Helper function to create the result object

View File

@ -1,6 +1,7 @@
import type { LanguageModelV1 } from '@ai-sdk/provider';
import { createFallback } from './ai-fallback';
import { anthropicModel } from './providers/anthropic';
import { openaiModel } from './providers/openai';
import { vertexModel } from './providers/vertex';
// Lazy initialization to allow mocking in tests
@ -24,13 +25,13 @@ function initializeSonnet4() {
}
}
// Only include Vertex if credentials are available
if (process.env.VERTEX_CLIENT_EMAIL && process.env.VERTEX_PRIVATE_KEY) {
if (process.env.OPENAI_API_KEY) {
try {
models.push(vertexModel('claude-sonnet-4@20250514'));
console.info('Sonnet4: Vertex AI model added to fallback chain');
models.push(openaiModel('gpt-5'));
console.info('Sonnet4: OpenAI model added to fallback chain');
} catch (error) {
console.warn('Sonnet4: Failed to initialize Vertex AI model:', error);
console.warn('Sonnet4: Failed to initialize OpenAI model:', error);
}
}