Skip to content

Commit cd50c11

Browse files
committed
feat: Tuning the setting specifically for Gemini
1 parent 2d84092 commit cd50c11

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

packages/types/src/provider-settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const baseProviderSettingsSchema = z.object({
5757
diffEnabled: z.boolean().optional(),
5858
fuzzyMatchThreshold: z.number().optional(),
5959
modelTemperature: z.number().nullish(),
60-
modelMaxContextWindow: z.number().nullish(),
6160
rateLimitSeconds: z.number().optional(),
6261

6362
// Model reasoning.
@@ -153,6 +152,7 @@ const lmStudioSchema = baseProviderSettingsSchema.extend({
153152
const geminiSchema = apiModelIdProviderModelSchema.extend({
154153
geminiApiKey: z.string().optional(),
155154
googleGeminiBaseUrl: z.string().optional(),
155+
modelMaxContextWindow: z.number().nullish(),
156156
})
157157

158158
const openAiNativeSchema = apiModelIdProviderModelSchema.extend({
@@ -319,6 +319,7 @@ export const PROVIDER_SETTINGS_KEYS = keysOf<ProviderSettings>()([
319319
// Gemini
320320
"geminiApiKey",
321321
"googleGeminiBaseUrl",
322+
"modelMaxContextWindow",
322323
// OpenAI Native
323324
"openAiNativeApiKey",
324325
"openAiNativeBaseUrl",
@@ -347,7 +348,6 @@ export const PROVIDER_SETTINGS_KEYS = keysOf<ProviderSettings>()([
347348
"diffEnabled",
348349
"fuzzyMatchThreshold",
349350
"modelTemperature",
350-
"modelMaxContextWindow",
351351
"rateLimitSeconds",
352352
// Fake AI
353353
"fakeAi",

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,15 @@ const ApiOptions = ({
485485
onChange={handleInputChange("modelTemperature", noTransform)}
486486
maxValue={2}
487487
/>
488-
<MaxContextWindowControl
489-
value={apiConfiguration.modelMaxContextWindow}
490-
onChange={handleInputChange("modelMaxContextWindow", noTransform)}
491-
maxValue={1000000}
492-
/>
488+
489+
{selectedProvider === "gemini" && (
490+
<MaxContextWindowControl
491+
value={apiConfiguration.modelMaxContextWindow}
492+
onChange={handleInputChange("modelMaxContextWindow", noTransform)}
493+
maxValue={1000000}
494+
/>
495+
)}
496+
493497
<RateLimitSecondsControl
494498
value={apiConfiguration.rateLimitSeconds || 0}
495499
onChange={(value) => setApiConfigurationField("rateLimitSeconds", value)}

webview-ui/src/components/settings/MaxContextWindowControl.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ interface MaxContextWindowControlProps {
1313

1414
export const MaxContextWindowControl = ({ value, onChange, maxValue = 1000000 }: MaxContextWindowControlProps) => {
1515
const { t } = useAppTranslation()
16-
const [isCustomTemperature, setIsCustomTemperature] = useState(value !== undefined)
16+
const [isCustomMaxContextWindow, setIsCustomMaxContextWindow] = useState(value !== undefined)
1717
const [inputValue, setInputValue] = useState(value)
1818

1919
useDebounce(() => onChange(inputValue), 50, [onChange, inputValue])
2020

2121
// Sync internal state with prop changes when switching profiles.
2222
useEffect(() => {
2323
const hasCustomTemperature = value !== undefined && value !== null
24-
setIsCustomTemperature(hasCustomTemperature)
24+
setIsCustomMaxContextWindow(hasCustomTemperature)
2525
setInputValue(value)
2626
}, [value])
2727

2828
return (
2929
<>
3030
<div>
3131
<VSCodeCheckbox
32-
checked={isCustomTemperature}
32+
checked={isCustomMaxContextWindow}
3333
onChange={(e: any) => {
3434
const isChecked = e.target.checked
35-
setIsCustomTemperature(isChecked)
35+
setIsCustomMaxContextWindow(isChecked)
3636

3737
if (!isChecked) {
3838
setInputValue(null) // Unset the temperature, note that undefined is unserializable.
@@ -47,7 +47,7 @@ export const MaxContextWindowControl = ({ value, onChange, maxValue = 1000000 }:
4747
</div>
4848
</div>
4949

50-
{isCustomTemperature && (
50+
{isCustomMaxContextWindow && (
5151
<div className="flex flex-col gap-3 pl-3 border-l-2 border-vscode-button-background">
5252
<div>
5353
<div className="flex items-center gap-2">

0 commit comments

Comments
 (0)