Skip to content

An AI-powered search engine with a generative UI

fix(models): allow newer model generations in dynamic model list (#1047)

Yoshiki Miuraa6af059ce783
diff --git a/lib/models/__tests__/fetch-models.test.ts b/lib/models/__tests__/fetch-models.test.ts
index 6deee66f..eb673a10 100644
--- a/lib/models/__tests__/fetch-models.test.ts
+++ b/lib/models/__tests__/fetch-models.test.ts
@@ -38,6 +38,7 @@ describe('fetch-models', () => {
json: async () => ({
data: [
{ id: 'gpt-5-mini' },
+ { id: 'gpt-6-luna' },
{ id: 'gpt-4o' },
{ id: 'gpt-5-2025-08-07' },
{ id: 'gpt-5-chat-latest' },
@@ -52,7 +53,41 @@ describe('fetch-models', () => {
vi.stubGlobal('fetch', fetchMock)
const models = await fetchModels.fetchOpenAIModels()
- expect(models.map(model => model.id)).toEqual(['gpt-5-mini', 'o3-mini'])
+ expect(models.map(model => model.id)).toEqual([
+ 'gpt-5-mini',
+ 'gpt-6-luna',
+ 'o3-mini'
+ ])
+ })
+
+ it('keeps current-generation Anthropic models', async () => {
+ mockIsProviderEnabled.mockImplementation(
+ providerId => providerId === 'anthropic'
+ )
+
+ const fetchMock = vi.fn().mockResolvedValue({
+ ok: true,
+ status: 200,
+ statusText: 'OK',
+ json: async () => ({
+ data: [
+ { id: 'claude-opus-5-5' },
+ { id: 'claude-fable-5-1' },
+ { id: 'claude-sonnet-4-5' },
+ { id: 'claude-3-5-haiku-20241022' },
+ { id: 'claude-3-opus-latest' }
+ ],
+ has_more: false
+ })
+ })
+ vi.stubGlobal('fetch', fetchMock)
+
+ const models = await fetchModels.fetchAnthropicModels()
+ expect(models.map(model => model.id)).toEqual([
+ 'claude-fable-5-1',
+ 'claude-opus-5-5',
+ 'claude-sonnet-4-5'
+ ])
})
it('groups models by provider and caches results', async () => {
diff --git a/lib/models/fetch-models.ts b/lib/models/fetch-models.ts
index 4aa7d588..0d6e64b3 100644
--- a/lib/models/fetch-models.ts
+++ b/lib/models/fetch-models.ts
@@ -8,7 +8,7 @@ export type ModelsByProvider = Record<string, Model[]>
const MODEL_CACHE_TTL_MS = 2 * 60 * 1000
const DATE_SNAPSHOT_SUFFIX_REGEX = /-\d{4}-\d{2}-\d{2}$/
const GOOGLE_PREVIEW_SNAPSHOT_REGEX = /preview-\d{2}-\d{2,4}$/i
-const OPENAI_ALLOWED_PREFIXES = ['gpt-5', 'o1', 'o3', 'o4']
+const OPENAI_ALLOWED_PATTERN = /^(gpt-([5-9]|\d{2,})|o[134])/
const OPENAI_EXCLUDED_KEYWORDS = [
'embed',
'tts',
@@ -28,11 +28,8 @@ const OPENAI_EXCLUDED_KEYWORDS = [
'instruct',
'chat-latest'
]
-const ANTHROPIC_ALLOWED_PREFIXES = [
- 'claude-opus-4',
- 'claude-sonnet-4',
- 'claude-haiku-4'
-]
+const ANTHROPIC_ALLOWED_PATTERN =
+ /^claude-(opus|sonnet|haiku|fable)-([4-9]|\d{2,})/
const GOOGLE_ALLOWED_PREFIXES = ['gemini-2.5', 'gemini-3']
const GOOGLE_EXCLUDED_KEYWORDS = ['image', 'live', 'native-audio', 'embedding']
const OPENAI_COMPATIBLE_EXCLUDED_KEYWORDS = [
@@ -93,7 +90,7 @@ function passesOpenAIFilters(id: string): boolean {
return false
}
- if (!OPENAI_ALLOWED_PREFIXES.some(prefix => id.startsWith(prefix))) {
+ if (!OPENAI_ALLOWED_PATTERN.test(id)) {
return false
}
@@ -107,7 +104,7 @@ function passesAnthropicFilters(id: string): boolean {
return false
}
- return ANTHROPIC_ALLOWED_PREFIXES.some(prefix => id.startsWith(prefix))
+ return ANTHROPIC_ALLOWED_PATTERN.test(id)
}
function passesGoogleFilters(id: string): boolean {