Skip to content

Commit 2a320d9

Browse files
committed
Refactor chatbot configuration to standardize Top P support and reasoning efforts, while adjusting preset saving logic and form layout
1 parent 8dae721 commit 2a320d9

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

‎packages/shared/src/constants/chatbots.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
type Chatbot = {
22
url: string
33
supports_custom_temperature?: boolean
4+
supports_custom_top_p?: boolean
45
supports_system_instructions?: boolean
56
supports_user_provided_model?: boolean
67
supports_user_provided_port?: boolean
78
supports_reasoning_effort?: boolean
9+
supported_reasoning_efforts?: string[]
810
supports_thinking_budget?: boolean
911
supports_url_override?: boolean
1012
url_override_label?: string
1113
url_override_disabled_options?: string[]
1214
default_system_instructions?: string
13-
default_top_p?: number
1415
supported_options?: {
1516
[option: string]: string
1617
}
@@ -27,10 +28,10 @@ export const CHATBOTS = {
2728
'AI Studio': {
2829
url: 'https://aistudio.google.com/prompts/new_chat',
2930
supports_custom_temperature: true,
31+
supports_custom_top_p: true,
3032
supports_system_instructions: true,
3133
supports_thinking_budget: true,
3234
default_system_instructions: "You're a helpful coding assistant.",
33-
default_top_p: 0.95,
3435
supported_options: {
3536
'temporary-chat': 'Temporary chat',
3637
'hide-panel': 'Hide panel',
@@ -182,22 +183,23 @@ export const CHATBOTS = {
182183
'Open WebUI': {
183184
url: 'http://openwebui/',
184185
supports_custom_temperature: true,
186+
supports_custom_top_p: true,
185187
supports_system_instructions: true,
186188
supports_user_provided_model: true,
187189
supports_user_provided_port: true,
188-
default_system_instructions: "You're a helpful coding assistant.",
189-
default_top_p: 0.9
190+
default_system_instructions: "You're a helpful coding assistant."
190191
} as Chatbot,
191192
OpenRouter: {
192193
url: 'https://openrouter.ai/chat',
193194
supports_custom_temperature: true,
195+
supports_custom_top_p: true,
194196
supports_system_instructions: true,
195197
supports_reasoning_effort: true,
198+
supported_reasoning_efforts: ['high', 'medium', 'low', 'minimal'],
196199
default_system_instructions: "You're a helpful coding assistant.",
197200
supported_options: {
198201
'disable-reasoning': 'Disable reasoning (for hybrid models)'
199-
},
200-
default_top_p: 1
202+
}
201203
} as Chatbot,
202204
Perplexity: {
203205
url: 'https://www.perplexity.ai/',

‎packages/vscode/src/views/panel/frontend/components/edit-preset-form/EditPresetForm/EditPresetForm.module.scss‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
display: flex;
1010
flex-direction: column;
1111
align-items: flex-start;
12-
gap: 8px;
12+
gap: 6px;
1313
}

‎packages/vscode/src/views/panel/frontend/components/edit-preset-form/EditPresetForm/EditPresetForm.tsx‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const EditPresetForm: React.FC<Props> = (props) => {
9999
}, [chatbot, new_url])
100100

101101
const supports_temperature = chatbot_config?.supports_custom_temperature
102-
const supports_top_p = chatbot_config?.default_top_p !== undefined
102+
const supports_top_p = chatbot_config?.supports_custom_top_p
103103
const supports_thinking_budget = chatbot_config?.supports_thinking_budget
104104
const supports_reasoning_effort =
105105
chatbot_config?.supports_reasoning_effort ||
@@ -118,10 +118,10 @@ export const EditPresetForm: React.FC<Props> = (props) => {
118118
chatbot,
119119
...(prompt_prefix ? { prompt_prefix } : {}),
120120
...(prompt_suffix ? { prompt_suffix } : {}),
121-
...(temperature !== undefined ? { temperature } : {}),
122-
...(!supports_top_p || top_p !== chatbot_config.default_top_p
123-
? { top_p }
121+
...(temperature !== undefined && temperature != 1
122+
? { temperature }
124123
: {}),
124+
...(top_p !== undefined && top_p != 0.95 ? { top_p } : {}),
125125
...(thinking_budget !== undefined ? { thinking_budget } : {}),
126126
...(reasoning_effort ? { reasoning_effort } : {}),
127127
...(model ? { model } : {}),
@@ -207,23 +207,21 @@ export const EditPresetForm: React.FC<Props> = (props) => {
207207
}
208208

209209
const reasoning_effort_options = useMemo(() => {
210-
if (model_info?.supported_reasoning_efforts) {
210+
const supported_efforts =
211+
chatbot_config?.supported_reasoning_efforts ||
212+
model_info?.supported_reasoning_efforts
213+
214+
if (supported_efforts) {
211215
return [
212216
{ value: '—', label: '—' },
213-
...model_info.supported_reasoning_efforts.map((effort: string) => {
217+
...supported_efforts.map((effort: string) => {
214218
const capitalized = effort.charAt(0).toUpperCase() + effort.slice(1)
215219
return { value: effort, label: capitalized }
216220
})
217221
]
218222
}
219-
return [
220-
{ value: '—', label: '—' },
221-
{ value: 'High', label: 'High' },
222-
{ value: 'Medium', label: 'Medium' },
223-
{ value: 'Low', label: 'Low' },
224-
{ value: 'Minimal', label: 'Minimal' }
225-
]
226-
}, [model_info])
223+
return [{ value: '—', label: '—' }]
224+
}, [chatbot_config, model_info])
227225

228226
useEffect(() => {
229227
if (
@@ -367,7 +365,7 @@ export const EditPresetForm: React.FC<Props> = (props) => {
367365
label="Reasoning Effort"
368366
html_for="reasoning-effort"
369367
info={`Controls how much the model thinks.${
370-
chatbot == 'OpenRouter' ? ' Requires reasoning model.' : ''
368+
chatbot == 'OpenRouter' ? ' Requires a reasoning model.' : ''
371369
}`}
372370
>
373371
<Dropdown
@@ -480,7 +478,7 @@ export const EditPresetForm: React.FC<Props> = (props) => {
480478
info="Influences response variety. Lower values are more predictable; higher values are more diverse."
481479
>
482480
<Slider
483-
value={temperature || 0.5}
481+
value={temperature ?? 1}
484482
onChange={set_temperature}
485483
min={0}
486484
max={2}
@@ -494,7 +492,7 @@ export const EditPresetForm: React.FC<Props> = (props) => {
494492
info="Limits token choices to cumulative probability P. Lower values make responses more predictable."
495493
>
496494
<Slider
497-
value={top_p || (chatbot && CHATBOTS[chatbot].default_top_p)!}
495+
value={top_p ?? 0.95}
498496
onChange={set_top_p}
499497
min={0}
500498
max={1}

0 commit comments

Comments
 (0)