Skip to content

Commit 7bd2114

Browse files
refactor(ai-gateway): extract model variant lists into constants (#3595)
Pull the inline Claude, Opus, Seed, and Mercury reasoning variant objects out of getModelVariants into named constants and reuse shared definitions via spread to reduce duplication. Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
1 parent 34866a4 commit 7bd2114

1 file changed

Lines changed: 32 additions & 27 deletions

File tree

apps/web/src/lib/ai-gateway/providers/model-settings.ts

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,40 @@ export const REASONING_VARIANTS_NONE_LOW_MEDIUM_HIGH = {
3535
...REASONING_VARIANTS_LOW_MEDIUM_HIGH,
3636
} as const;
3737

38+
const REASONING_VARIANTS_CLAUDE_BASE = {
39+
none: { reasoning: { enabled: false, effort: 'none' } },
40+
low: { reasoning: { enabled: true, effort: 'low' }, verbosity: 'low' },
41+
medium: { reasoning: { enabled: true, effort: 'medium' }, verbosity: 'medium' },
42+
high: { reasoning: { enabled: true, effort: 'high' }, verbosity: 'high' },
43+
} as const;
44+
45+
export const REASONING_VARIANTS_CLAUDE = {
46+
...REASONING_VARIANTS_CLAUDE_BASE,
47+
max: { reasoning: { enabled: true, effort: 'xhigh' }, verbosity: 'max' },
48+
} as const;
49+
50+
export const REASONING_VARIANTS_OPUS = {
51+
...REASONING_VARIANTS_CLAUDE_BASE,
52+
xhigh: { reasoning: { enabled: true, effort: 'xhigh' }, verbosity: 'xhigh' },
53+
max: { reasoning: { enabled: true, effort: 'xhigh' }, verbosity: 'max' },
54+
} as const;
55+
56+
export const REASONING_VARIANTS_SEED = {
57+
none: { reasoning: { enabled: false, effort: 'minimal' } },
58+
...REASONING_VARIANTS_LOW_MEDIUM_HIGH,
59+
} as const;
60+
61+
export const REASONING_VARIANTS_INSTANT_LOW_MEDIUM_HIGH = {
62+
instant: REASONING_VARIANTS_BINARY.instant,
63+
...REASONING_VARIANTS_LOW_MEDIUM_HIGH,
64+
} as const;
65+
3866
export function getModelVariants(model: string): OpenCodeSettings['variants'] {
3967
if (isOpusModel(model) && (model.includes('4.7') || model.includes('4.8'))) {
40-
return {
41-
none: { reasoning: { enabled: false, effort: 'none' } },
42-
low: { reasoning: { enabled: true, effort: 'low' }, verbosity: 'low' },
43-
medium: { reasoning: { enabled: true, effort: 'medium' }, verbosity: 'medium' },
44-
high: { reasoning: { enabled: true, effort: 'high' }, verbosity: 'high' },
45-
xhigh: { reasoning: { enabled: true, effort: 'xhigh' }, verbosity: 'xhigh' },
46-
max: { reasoning: { enabled: true, effort: 'xhigh' }, verbosity: 'max' },
47-
};
68+
return REASONING_VARIANTS_OPUS;
4869
}
4970
if (isClaudeModel(model)) {
50-
return {
51-
none: { reasoning: { enabled: false, effort: 'none' } },
52-
low: { reasoning: { enabled: true, effort: 'low' }, verbosity: 'low' },
53-
medium: { reasoning: { enabled: true, effort: 'medium' }, verbosity: 'medium' },
54-
high: { reasoning: { enabled: true, effort: 'high' }, verbosity: 'high' },
55-
max: { reasoning: { enabled: true, effort: 'xhigh' }, verbosity: 'max' },
56-
};
71+
return REASONING_VARIANTS_CLAUDE;
5772
}
5873
if (model.includes('codex') || isGemini3Model(model)) {
5974
return Object.fromEntries(
@@ -80,20 +95,10 @@ export function getModelVariants(model: string): OpenCodeSettings['variants'] {
8095
return REASONING_VARIANTS_BINARY;
8196
}
8297
if (model === seed_20_code_free_model.public_id) {
83-
return {
84-
none: { reasoning: { enabled: false, effort: 'minimal' } },
85-
low: { reasoning: { enabled: true, effort: 'low' } },
86-
medium: { reasoning: { enabled: true, effort: 'medium' } },
87-
high: { reasoning: { enabled: true, effort: 'high' } },
88-
};
98+
return REASONING_VARIANTS_SEED;
8999
}
90100
if (model.startsWith('inception/mercury-2')) {
91-
return {
92-
instant: { reasoning: { enabled: false, effort: 'none' } },
93-
low: { reasoning: { enabled: true, effort: 'low' } },
94-
medium: { reasoning: { enabled: true, effort: 'medium' } },
95-
high: { reasoning: { enabled: true, effort: 'high' } },
96-
};
101+
return REASONING_VARIANTS_INSTANT_LOW_MEDIUM_HIGH;
97102
}
98103
if (isStepModel(model)) {
99104
return REASONING_VARIANTS_LOW_MEDIUM_HIGH;

0 commit comments

Comments
 (0)