Skip to content

Commit 05a24b8

Browse files
committed
Remove temperature from API configuration descriptions and ensure reasoning effort is displayed instead
- in voice input handler, the configurations list in the quick pick doesnt show reasoning effort - in the configurations quick pick, don't show temperature
1 parent 30ae798 commit 05a24b8

7 files changed

Lines changed: 359 additions & 286 deletions

File tree

‎apps/editor/src/commands/code-at-cursor-command/utils/get-code-at-cursor-config.ts‎

Lines changed: 66 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export const get_code_at_cursor_api_configuration = async (params: {
5151
(c) => get_api_configuration_id(c) == last_selected_id
5252
) || null
5353
}
54-
if (!selected_api_configuration && code_at_cursor_api_configurations.length > 0) {
54+
if (
55+
!selected_api_configuration &&
56+
code_at_cursor_api_configurations.length > 0
57+
) {
5558
selected_api_configuration = code_at_cursor_api_configurations[0]
5659
}
5760
}
@@ -85,11 +88,10 @@ export const get_code_at_cursor_api_configuration = async (params: {
8588
const recent_api_configurations = matched_recent_api_configurations
8689
const other_api_configurations = remaining_api_configurations
8790

88-
const map_api_configuration_to_item = (api_configuration: ApiConfiguration) => {
91+
const map_api_configuration_to_item = (
92+
api_configuration: ApiConfiguration
93+
) => {
8994
const description_parts = [api_configuration.model_provider_name]
90-
if (api_configuration.temperature != null) {
91-
description_parts.push(`${api_configuration.temperature}`)
92-
}
9395
if (api_configuration.reasoning_effort) {
9496
description_parts.push(`${api_configuration.reasoning_effort}`)
9597
}
@@ -115,7 +117,9 @@ export const get_code_at_cursor_api_configuration = async (params: {
115117
label: t('common.separator.recently-used'),
116118
kind: vscode.QuickPickItemKind.Separator
117119
})
118-
items.push(...recent_api_configurations.map(map_api_configuration_to_item))
120+
items.push(
121+
...recent_api_configurations.map(map_api_configuration_to_item)
122+
)
119123
}
120124

121125
if (other_api_configurations.length > 0) {
@@ -125,7 +129,9 @@ export const get_code_at_cursor_api_configuration = async (params: {
125129
kind: vscode.QuickPickItemKind.Separator
126130
})
127131
}
128-
items.push(...other_api_configurations.map(map_api_configuration_to_item))
132+
items.push(
133+
...other_api_configurations.map(map_api_configuration_to_item)
134+
)
129135
}
130136

131137
return items
@@ -154,67 +160,68 @@ export const get_code_at_cursor_api_configuration = async (params: {
154160
}
155161
}
156162

157-
return new Promise<{ model_provider: any; api_configuration: any } | undefined>(
158-
(resolve) => {
159-
quick_pick.onDidTriggerButton((button) => {
160-
if (button.tooltip == t('common.close')) {
161-
quick_pick.hide()
162-
resolve(undefined)
163-
}
164-
})
165-
166-
quick_pick.onDidAccept(async () => {
167-
const selected = quick_pick.selectedItems[0] as any
163+
return new Promise<
164+
{ model_provider: any; api_configuration: any } | undefined
165+
>((resolve) => {
166+
quick_pick.onDidTriggerButton((button) => {
167+
if (button.tooltip == t('common.close')) {
168168
quick_pick.hide()
169+
resolve(undefined)
170+
}
171+
})
169172

170-
if (!selected || !selected.api_configuration) {
171-
resolve(undefined)
172-
return
173-
}
174-
175-
let recents =
176-
params.context.workspaceState.get<string[]>(
177-
RECENTLY_USED_CODE_AT_CURSOR_CONFIG_IDS_STATE_KEY
178-
) || []
179-
recents = [selected.id, ...recents.filter((id) => id != selected.id)]
180-
params.context.workspaceState.update(
181-
RECENTLY_USED_CODE_AT_CURSOR_CONFIG_IDS_STATE_KEY,
182-
recents
183-
)
173+
quick_pick.onDidAccept(async () => {
174+
const selected = quick_pick.selectedItems[0] as any
175+
quick_pick.hide()
184176

185-
if (params.panel_provider) {
186-
params.panel_provider.send_message({
187-
command: 'SELECTED_API_CONFIGURATION_CHANGED',
188-
prompt_type: 'code-at-cursor',
189-
id: selected.id
190-
})
191-
}
177+
if (!selected || !selected.api_configuration) {
178+
resolve(undefined)
179+
return
180+
}
192181

193-
const model_provider = await params.api_providers_manager.get_model_provider(
194-
selected.api_configuration.model_provider_name
195-
)
196-
if (!model_provider) {
197-
vscode.window.showErrorMessage(
198-
dictionary.error_message.API_PROVIDER_NOT_FOUND
199-
)
200-
resolve(undefined)
201-
return
202-
}
203-
204-
resolve({
205-
model_provider,
206-
api_configuration: selected.api_configuration
182+
let recents =
183+
params.context.workspaceState.get<string[]>(
184+
RECENTLY_USED_CODE_AT_CURSOR_CONFIG_IDS_STATE_KEY
185+
) || []
186+
recents = [selected.id, ...recents.filter((id) => id != selected.id)]
187+
params.context.workspaceState.update(
188+
RECENTLY_USED_CODE_AT_CURSOR_CONFIG_IDS_STATE_KEY,
189+
recents
190+
)
191+
192+
if (params.panel_provider) {
193+
params.panel_provider.send_message({
194+
command: 'SELECTED_API_CONFIGURATION_CHANGED',
195+
prompt_type: 'code-at-cursor',
196+
id: selected.id
207197
})
208-
})
198+
}
209199

210-
quick_pick.onDidHide(() => {
211-
quick_pick.dispose()
200+
const model_provider =
201+
await params.api_providers_manager.get_model_provider(
202+
selected.api_configuration.model_provider_name
203+
)
204+
if (!model_provider) {
205+
vscode.window.showErrorMessage(
206+
dictionary.error_message.API_PROVIDER_NOT_FOUND
207+
)
212208
resolve(undefined)
209+
return
210+
}
211+
212+
resolve({
213+
model_provider,
214+
api_configuration: selected.api_configuration
213215
})
216+
})
214217

215-
quick_pick.show()
216-
}
217-
)
218+
quick_pick.onDidHide(() => {
219+
quick_pick.dispose()
220+
resolve(undefined)
221+
})
222+
223+
quick_pick.show()
224+
})
218225
}
219226

220227
const model_provider = await params.api_providers_manager.get_model_provider(

‎apps/editor/src/commands/find-relevant-files-command/utils/prompt-for-config.ts‎

Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export const prompt_for_api_configuration = async (params: {
1616
tokens_to_process: number
1717
force_prompt?: boolean
1818
}): Promise<
19-
| { api_configuration: ApiConfiguration; model_provider: ModelProvider; skipped: boolean }
19+
| {
20+
api_configuration: ApiConfiguration
21+
model_provider: ModelProvider
22+
skipped: boolean
23+
}
2024
| 'back'
2125
| 'cancel'
2226
> => {
@@ -45,25 +49,27 @@ export const prompt_for_api_configuration = async (params: {
4549
const matched_recent_api_configurations: ApiConfiguration[] = []
4650
const remaining_api_configurations: ApiConfiguration[] = []
4751

48-
params.api_configurations.forEach((api_configuration: ApiConfiguration) => {
49-
const id = get_api_configuration_id(api_configuration)
50-
if (recent_ids.includes(id)) {
51-
matched_recent_api_configurations.push(api_configuration)
52-
} else {
53-
remaining_api_configurations.push(api_configuration)
52+
params.api_configurations.forEach(
53+
(api_configuration: ApiConfiguration) => {
54+
const id = get_api_configuration_id(api_configuration)
55+
if (recent_ids.includes(id)) {
56+
matched_recent_api_configurations.push(api_configuration)
57+
} else {
58+
remaining_api_configurations.push(api_configuration)
59+
}
5460
}
55-
})
61+
)
5662

5763
matched_recent_api_configurations.sort((a, b) => {
5864
const id_a = get_api_configuration_id(a)
5965
const id_b = get_api_configuration_id(b)
6066
return recent_ids.indexOf(id_a) - recent_ids.indexOf(id_b)
6167
})
6268

63-
const map_api_configuration_to_item = (api_configuration: ApiConfiguration) => {
69+
const map_api_configuration_to_item = (
70+
api_configuration: ApiConfiguration
71+
) => {
6472
const description_parts = [api_configuration.model_provider_name]
65-
if (api_configuration.temperature != null)
66-
description_parts.push(`${api_configuration.temperature}`)
6773
if (api_configuration.reasoning_effort)
6874
description_parts.push(`${api_configuration.reasoning_effort}`)
6975

@@ -85,7 +91,11 @@ export const prompt_for_api_configuration = async (params: {
8591
label: t('common.separator.recently-used'),
8692
kind: vscode.QuickPickItemKind.Separator
8793
})
88-
items.push(...matched_recent_api_configurations.map(map_api_configuration_to_item))
94+
items.push(
95+
...matched_recent_api_configurations.map(
96+
map_api_configuration_to_item
97+
)
98+
)
8999
}
90100
if (remaining_api_configurations.length > 0) {
91101
if (matched_recent_api_configurations.length > 0) {
@@ -94,55 +104,61 @@ export const prompt_for_api_configuration = async (params: {
94104
kind: vscode.QuickPickItemKind.Separator
95105
})
96106
}
97-
items.push(...remaining_api_configurations.map(map_api_configuration_to_item))
107+
items.push(
108+
...remaining_api_configurations.map(map_api_configuration_to_item)
109+
)
98110
}
99111
return items
100112
}
101113

102114
const api_configuration_quick_pick = vscode.window.createQuickPick()
103115
api_configuration_quick_pick.items = create_items()
104116
api_configuration_quick_pick.title = t('common.config.title')
105-
api_configuration_quick_pick.placeholder = t('common.config.placeholder-with-tokens', {
106-
tokens: display_token_count(params.tokens_to_process)
107-
})
117+
api_configuration_quick_pick.placeholder = t(
118+
'common.config.placeholder-with-tokens',
119+
{
120+
tokens: display_token_count(params.tokens_to_process)
121+
}
122+
)
108123
api_configuration_quick_pick.matchOnDescription = true
109124
api_configuration_quick_pick.buttons = [vscode.QuickInputButtons.Back]
110125

111-
const items = api_configuration_quick_pick.items as (vscode.QuickPickItem & {
112-
id?: string
113-
})[]
126+
const items =
127+
api_configuration_quick_pick.items as (vscode.QuickPickItem & {
128+
id?: string
129+
})[]
114130
const first_selectable = items.find(
115131
(i) => i.kind !== vscode.QuickPickItemKind.Separator
116132
)
117133
if (first_selectable) {
118134
api_configuration_quick_pick.activeItems = [first_selectable]
119135
}
120136

121-
const api_configuration_result = await new Promise<ApiConfiguration | 'back' | 'cancel'>(
122-
(resolve) => {
123-
let is_resolved = false
124-
api_configuration_quick_pick.onDidTriggerButton((button) => {
125-
if (button === vscode.QuickInputButtons.Back) {
126-
is_resolved = true
127-
resolve('back')
128-
api_configuration_quick_pick.hide()
129-
}
130-
})
131-
api_configuration_quick_pick.onDidAccept(() => {
137+
const api_configuration_result = await new Promise<
138+
ApiConfiguration | 'back' | 'cancel'
139+
>((resolve) => {
140+
let is_resolved = false
141+
api_configuration_quick_pick.onDidTriggerButton((button) => {
142+
if (button === vscode.QuickInputButtons.Back) {
132143
is_resolved = true
133-
const selected = api_configuration_quick_pick.selectedItems[0] as any
134-
resolve(selected?.api_configuration)
144+
resolve('back')
135145
api_configuration_quick_pick.hide()
136-
})
137-
api_configuration_quick_pick.onDidHide(() => {
138-
if (!is_resolved) {
139-
resolve('cancel')
140-
}
141-
api_configuration_quick_pick.dispose()
142-
})
143-
api_configuration_quick_pick.show()
144-
}
145-
)
146+
}
147+
})
148+
api_configuration_quick_pick.onDidAccept(() => {
149+
is_resolved = true
150+
const selected = api_configuration_quick_pick.selectedItems[0] as any
151+
resolve(selected?.api_configuration)
152+
api_configuration_quick_pick.hide()
153+
})
154+
api_configuration_quick_pick.onDidHide(() => {
155+
if (!is_resolved) {
156+
resolve('cancel')
157+
}
158+
api_configuration_quick_pick.dispose()
159+
})
160+
api_configuration_quick_pick.show()
161+
})
146162

147163
if (api_configuration_result === 'back') return 'back'
148164
if (api_configuration_result === 'cancel') return 'cancel'
@@ -175,5 +191,9 @@ export const prompt_for_api_configuration = async (params: {
175191
return 'cancel'
176192
}
177193

178-
return { api_configuration: selected_api_configuration, model_provider, skipped }
194+
return {
195+
api_configuration: selected_api_configuration,
196+
model_provider,
197+
skipped
198+
}
179199
}

‎apps/editor/src/commands/generate-commit-message-command/utils/get-commit-message-config.ts‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ export const get_commit_message_api_configuration = async (
3232
| null
3333
> => {
3434
const api_providers_manager = new ModelProvidersManager(context)
35-
let commit_message_api_configuration: CommitMessageApiConfiguration | null | undefined | 'back' =
36-
force_quick_pick
37-
? undefined
38-
: await api_providers_manager.get_default_commit_messages_api_configuration()
35+
let commit_message_api_configuration:
36+
| CommitMessageApiConfiguration
37+
| null
38+
| undefined
39+
| 'back' = force_quick_pick
40+
? undefined
41+
: await api_providers_manager.get_default_commit_messages_api_configuration()
3942

4043
if (!commit_message_api_configuration) {
41-
const api_configurations = await api_providers_manager.get_api_configurations()
44+
const api_configurations =
45+
await api_providers_manager.get_api_configurations()
4246

4347
if (api_configurations.length == 0) {
4448
vscode.commands.executeCommand('codeWebChat.settings')
@@ -78,14 +82,13 @@ export const get_commit_message_api_configuration = async (
7882
const recent_api_configurations = matched_recent_api_configurations
7983
const other_api_configurations = remaining_api_configurations
8084

81-
const map_api_configuration_to_item = (api_configuration: ApiConfiguration) => {
85+
const map_api_configuration_to_item = (
86+
api_configuration: ApiConfiguration
87+
) => {
8288
const description_parts = [api_configuration.model_provider_name]
8389
if (api_configuration.reasoning_effort) {
8490
description_parts.push(`${api_configuration.reasoning_effort}`)
8591
}
86-
if (api_configuration.temperature != null) {
87-
description_parts.push(`${api_configuration.temperature}`)
88-
}
8992

9093
return {
9194
label: api_configuration.model,
@@ -105,7 +108,9 @@ export const get_commit_message_api_configuration = async (
105108
label: t('common.separator.recently-used'),
106109
kind: vscode.QuickPickItemKind.Separator
107110
})
108-
items.push(...recent_api_configurations.map(map_api_configuration_to_item))
111+
items.push(
112+
...recent_api_configurations.map(map_api_configuration_to_item)
113+
)
109114
}
110115

111116
if (other_api_configurations.length > 0) {
@@ -115,7 +120,9 @@ export const get_commit_message_api_configuration = async (
115120
kind: vscode.QuickPickItemKind.Separator
116121
})
117122
}
118-
items.push(...other_api_configurations.map(map_api_configuration_to_item))
123+
items.push(
124+
...other_api_configurations.map(map_api_configuration_to_item)
125+
)
119126
}
120127

121128
return items

0 commit comments

Comments
 (0)