Skip to content

Commit 013176a

Browse files
committed
refactor(providers): deduplicate bundled model catalogs
1 parent 85fd4c9 commit 013176a

3 files changed

Lines changed: 142 additions & 389 deletions

File tree

‎extensions/google/provider-catalog.ts‎

Lines changed: 29 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -14,95 +14,36 @@ const GOOGLE_GEMINI_MODELS_ENDPOINT = `${GOOGLE_GEMINI_BASE_URL}/models?pageSize
1414
const GOOGLE_VERTEX_BASE_URL = "https://{location}-aiplatform.googleapis.com";
1515
const GOOGLE_GEMINI_MODELS_CACHE_TTL_MS = 60_000;
1616
const GOOGLE_GEMINI_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } as const;
17-
const GOOGLE_GEMINI_TEXT_MODELS: ModelDefinitionConfig[] = [
18-
{
19-
id: "gemini-2.5-pro",
20-
name: "Gemini 2.5 Pro",
21-
reasoning: true,
22-
input: ["text", "image"],
23-
cost: GOOGLE_GEMINI_COST,
24-
contextWindow: 1_048_576,
25-
maxTokens: 65_536,
26-
},
27-
{
28-
id: "gemini-2.5-flash",
29-
name: "Gemini 2.5 Flash",
30-
reasoning: true,
31-
input: ["text", "image"],
32-
cost: GOOGLE_GEMINI_COST,
33-
contextWindow: 1_048_576,
34-
maxTokens: 65_536,
35-
},
36-
{
37-
id: "gemini-2.5-flash-lite",
38-
name: "Gemini 2.5 Flash-Lite",
39-
reasoning: true,
40-
input: ["text", "image"],
41-
cost: GOOGLE_GEMINI_COST,
42-
contextWindow: 1_048_576,
43-
maxTokens: 65_536,
44-
},
45-
{
46-
id: "gemini-3.5-flash",
47-
name: "Gemini 3.5 Flash",
48-
reasoning: true,
49-
input: ["text", "image"],
50-
cost: GOOGLE_GEMINI_COST,
51-
contextWindow: 1_048_576,
52-
maxTokens: 65_536,
53-
compat: { codeMode: "preferred" },
54-
},
55-
{
56-
id: "gemini-3.6-flash",
57-
name: "Gemini 3.6 Flash",
58-
reasoning: true,
59-
input: ["text", "image"],
60-
cost: GOOGLE_GEMINI_COST,
61-
contextWindow: 1_048_576,
62-
maxTokens: 65_536,
63-
compat: { codeMode: "preferred" },
64-
},
65-
{
66-
id: "gemini-3.5-flash-lite",
67-
name: "Gemini 3.5 Flash-Lite",
68-
reasoning: true,
69-
input: ["text", "image"],
70-
cost: GOOGLE_GEMINI_COST,
71-
contextWindow: 1_048_576,
72-
maxTokens: 65_536,
73-
compat: { codeMode: "preferred" },
74-
},
75-
{
76-
id: "gemini-3.1-pro-preview",
77-
name: "Gemini 3.1 Pro Preview",
78-
reasoning: true,
79-
input: ["text", "image"],
80-
cost: GOOGLE_GEMINI_COST,
81-
contextWindow: 1_048_576,
82-
maxTokens: 65_536,
83-
compat: { codeMode: "preferred" },
84-
},
85-
{
86-
id: "gemini-3.1-flash-lite",
87-
name: "Gemini 3.1 Flash Lite",
88-
reasoning: true,
89-
input: ["text", "image"],
90-
cost: GOOGLE_GEMINI_COST,
91-
contextWindow: 1_048_576,
92-
maxTokens: 65_536,
93-
compat: { codeMode: "preferred" },
94-
},
95-
{
96-
id: "gemini-3-flash-preview",
97-
name: "Gemini 3 Flash Preview",
98-
reasoning: true,
99-
input: ["text", "image"],
100-
cost: GOOGLE_GEMINI_COST,
101-
contextWindow: 1_048_576,
102-
maxTokens: 65_536,
103-
compat: { codeMode: "preferred" },
104-
},
17+
const GOOGLE_GEMINI_TEXT_MODEL_ROWS: ReadonlyArray<
18+
readonly [id: string, name: string, prefersCodeMode: boolean]
19+
> = [
20+
["gemini-2.5-pro", "Gemini 2.5 Pro", false],
21+
["gemini-2.5-flash", "Gemini 2.5 Flash", false],
22+
["gemini-2.5-flash-lite", "Gemini 2.5 Flash-Lite", false],
23+
["gemini-3.5-flash", "Gemini 3.5 Flash", true],
24+
["gemini-3.6-flash", "Gemini 3.6 Flash", true],
25+
["gemini-3.5-flash-lite", "Gemini 3.5 Flash-Lite", true],
26+
["gemini-3.1-pro-preview", "Gemini 3.1 Pro Preview", true],
27+
["gemini-3.1-flash-lite", "Gemini 3.1 Flash Lite", true],
28+
["gemini-3-flash-preview", "Gemini 3 Flash Preview", true],
10529
];
30+
const GOOGLE_GEMINI_TEXT_MODELS: ModelDefinitionConfig[] = GOOGLE_GEMINI_TEXT_MODEL_ROWS.map(
31+
([id, name, prefersCodeMode]): ModelDefinitionConfig => {
32+
const model: ModelDefinitionConfig = {
33+
id,
34+
name,
35+
reasoning: true,
36+
input: ["text", "image"],
37+
cost: GOOGLE_GEMINI_COST,
38+
contextWindow: 1_048_576,
39+
maxTokens: 65_536,
40+
};
41+
if (prefersCodeMode) {
42+
model.compat = { codeMode: "preferred" };
43+
}
44+
return model;
45+
},
46+
);
10647
const GOOGLE_GEMINI_TEXT_MODEL_BY_ID = new Map(
10748
GOOGLE_GEMINI_TEXT_MODELS.map((model) => [model.id, model]),
10849
);

‎extensions/qwen/models.ts‎

Lines changed: 43 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -68,175 +68,52 @@ export function resolveQwenTokenPlanBaseUrl(region: QwenTokenPlanRegion): string
6868
return QWEN_TOKEN_PLAN_BASE_URLS[region];
6969
}
7070

71-
// Token Plan is credit-based, so per-token prices do not map to its billing model.
72-
// This curated picker catalog keeps current recommendations plus one selectable compatibility row.
73-
export const QWEN_TOKEN_PLAN_MODEL_CATALOG: ReadonlyArray<ModelDefinitionConfig> = [
74-
{
75-
id: QWEN_37_PLUS_MODEL_ID,
76-
name: QWEN_37_PLUS_MODEL_ID,
77-
reasoning: true,
78-
input: ["text", "image"],
79-
cost: QWEN_DEFAULT_COST,
80-
contextWindow: 1_000_000,
81-
maxTokens: 65_536,
82-
},
83-
{
84-
id: QWEN_36_PLUS_MODEL_ID,
85-
name: QWEN_36_PLUS_MODEL_ID,
86-
reasoning: true,
87-
input: ["text", "image"],
88-
cost: QWEN_DEFAULT_COST,
89-
contextWindow: 1_000_000,
90-
maxTokens: 65_536,
91-
},
92-
{
93-
id: "qwen3-coder-next",
94-
name: "qwen3-coder-next",
95-
reasoning: true,
96-
input: ["text"],
97-
cost: QWEN_DEFAULT_COST,
98-
contextWindow: 262_144,
99-
maxTokens: 65_536,
100-
},
101-
{
102-
id: "kimi-k2.5",
103-
name: "kimi-k2.5",
104-
reasoning: true,
105-
input: ["text", "image"],
106-
cost: QWEN_DEFAULT_COST,
107-
contextWindow: 262_144,
108-
maxTokens: 98_304,
109-
},
110-
{
111-
id: "glm-5",
112-
name: "glm-5",
113-
reasoning: true,
114-
input: ["text"],
115-
cost: QWEN_DEFAULT_COST,
116-
contextWindow: 202_752,
117-
maxTokens: 16_384,
118-
},
119-
{
120-
id: "MiniMax-M2.5",
121-
name: "MiniMax-M2.5",
122-
reasoning: true,
123-
input: ["text"],
124-
cost: QWEN_DEFAULT_COST,
125-
contextWindow: 196_608,
126-
maxTokens: 32_768,
127-
},
71+
type QwenCatalogModelRow = readonly [
72+
id: string,
73+
reasoning: boolean,
74+
input: ModelDefinitionConfig["input"],
75+
contextWindow: number,
76+
maxTokens: number,
12877
];
12978

130-
export const QWEN_MODEL_CATALOG: ReadonlyArray<ModelDefinitionConfig> = [
131-
{
132-
id: "qwen3.5-plus",
133-
name: "qwen3.5-plus",
134-
reasoning: false,
135-
input: ["text", "image"],
136-
cost: QWEN_DEFAULT_COST,
137-
contextWindow: 1_000_000,
138-
maxTokens: 65_536,
139-
},
140-
{
141-
id: QWEN_36_FLASH_MODEL_ID,
142-
name: QWEN_36_FLASH_MODEL_ID,
143-
reasoning: true,
144-
input: ["text", "image"],
145-
cost: QWEN_DEFAULT_COST,
146-
contextWindow: 1_000_000,
147-
maxTokens: 65_536,
148-
},
149-
{
150-
id: QWEN_36_PLUS_MODEL_ID,
151-
name: QWEN_36_PLUS_MODEL_ID,
152-
reasoning: true,
153-
input: ["text", "image"],
154-
cost: QWEN_DEFAULT_COST,
155-
contextWindow: 1_000_000,
156-
maxTokens: 65_536,
157-
},
158-
{
159-
id: QWEN_37_MAX_MODEL_ID,
160-
name: QWEN_37_MAX_MODEL_ID,
161-
reasoning: true,
162-
input: ["text"],
163-
cost: QWEN_DEFAULT_COST,
164-
contextWindow: 1_000_000,
165-
maxTokens: 65_536,
166-
},
167-
{
168-
id: QWEN_37_PLUS_MODEL_ID,
169-
name: QWEN_37_PLUS_MODEL_ID,
170-
reasoning: true,
171-
input: ["text", "image"],
172-
cost: QWEN_DEFAULT_COST,
173-
contextWindow: 1_000_000,
174-
maxTokens: 65_536,
175-
},
176-
{
177-
id: "qwen3-max-2026-01-23",
178-
name: "qwen3-max-2026-01-23",
179-
reasoning: false,
180-
input: ["text"],
79+
function buildQwenCatalogModels(rows: readonly QwenCatalogModelRow[]): ModelDefinitionConfig[] {
80+
return rows.map(([id, reasoning, input, contextWindow, maxTokens]) => ({
81+
id,
82+
name: id,
83+
reasoning,
84+
input,
18185
cost: QWEN_DEFAULT_COST,
182-
contextWindow: 262_144,
183-
maxTokens: 65_536,
184-
},
185-
{
186-
id: "qwen3-coder-next",
187-
name: "qwen3-coder-next",
188-
reasoning: false,
189-
input: ["text"],
190-
cost: QWEN_DEFAULT_COST,
191-
contextWindow: 262_144,
192-
maxTokens: 65_536,
193-
},
194-
{
195-
id: "qwen3-coder-plus",
196-
name: "qwen3-coder-plus",
197-
reasoning: false,
198-
input: ["text"],
199-
cost: QWEN_DEFAULT_COST,
200-
contextWindow: 1_000_000,
201-
maxTokens: 65_536,
202-
},
203-
{
204-
id: "MiniMax-M2.5",
205-
name: "MiniMax-M2.5",
206-
reasoning: true,
207-
input: ["text"],
208-
cost: QWEN_DEFAULT_COST,
209-
contextWindow: 1_000_000,
210-
maxTokens: 65_536,
211-
},
212-
{
213-
id: "glm-5",
214-
name: "glm-5",
215-
reasoning: false,
216-
input: ["text"],
217-
cost: QWEN_DEFAULT_COST,
218-
contextWindow: 202_752,
219-
maxTokens: 16_384,
220-
},
221-
{
222-
id: "glm-4.7",
223-
name: "glm-4.7",
224-
reasoning: false,
225-
input: ["text"],
226-
cost: QWEN_DEFAULT_COST,
227-
contextWindow: 202_752,
228-
maxTokens: 16_384,
229-
},
230-
{
231-
id: "kimi-k2.5",
232-
name: "kimi-k2.5",
233-
reasoning: false,
234-
input: ["text", "image"],
235-
cost: QWEN_DEFAULT_COST,
236-
contextWindow: 262_144,
237-
maxTokens: 32_768,
238-
},
239-
];
86+
contextWindow,
87+
maxTokens,
88+
}));
89+
}
90+
91+
// Token Plan is credit-based, so per-token prices do not map to its billing model.
92+
// This curated picker catalog keeps current recommendations plus one selectable compatibility row.
93+
export const QWEN_TOKEN_PLAN_MODEL_CATALOG: ReadonlyArray<ModelDefinitionConfig> =
94+
buildQwenCatalogModels([
95+
[QWEN_37_PLUS_MODEL_ID, true, ["text", "image"], 1_000_000, 65_536],
96+
[QWEN_36_PLUS_MODEL_ID, true, ["text", "image"], 1_000_000, 65_536],
97+
["qwen3-coder-next", true, ["text"], 262_144, 65_536],
98+
["kimi-k2.5", true, ["text", "image"], 262_144, 98_304],
99+
["glm-5", true, ["text"], 202_752, 16_384],
100+
["MiniMax-M2.5", true, ["text"], 196_608, 32_768],
101+
]);
102+
103+
export const QWEN_MODEL_CATALOG: ReadonlyArray<ModelDefinitionConfig> = buildQwenCatalogModels([
104+
[QWEN_DEFAULT_MODEL_ID, false, ["text", "image"], 1_000_000, 65_536],
105+
[QWEN_36_FLASH_MODEL_ID, true, ["text", "image"], 1_000_000, 65_536],
106+
[QWEN_36_PLUS_MODEL_ID, true, ["text", "image"], 1_000_000, 65_536],
107+
[QWEN_37_MAX_MODEL_ID, true, ["text"], 1_000_000, 65_536],
108+
[QWEN_37_PLUS_MODEL_ID, true, ["text", "image"], 1_000_000, 65_536],
109+
["qwen3-max-2026-01-23", false, ["text"], 262_144, 65_536],
110+
["qwen3-coder-next", false, ["text"], 262_144, 65_536],
111+
["qwen3-coder-plus", false, ["text"], 1_000_000, 65_536],
112+
["MiniMax-M2.5", true, ["text"], 1_000_000, 65_536],
113+
["glm-5", false, ["text"], 202_752, 16_384],
114+
["glm-4.7", false, ["text"], 202_752, 16_384],
115+
["kimi-k2.5", false, ["text", "image"], 262_144, 32_768],
116+
]);
240117

241118
export function isQwenCodingPlanBaseUrl(baseUrl: string | undefined): boolean {
242119
const trimmed = baseUrl?.trim();

0 commit comments

Comments
 (0)