|
1 | 1 | import { SettingsProvider } from '@/views/settings/backend/settings-provider' |
2 | 2 | import { |
3 | 3 | ModelProvidersManager, |
4 | | - ApiConfiguration, |
5 | 4 | get_api_configuration_id |
6 | 5 | } from '@/services/model-providers-manager' |
7 | | -import { ApiConfigurationForClient } from '@/views/settings/types/messages' |
8 | | - |
9 | | -const create_description = (api_configuration: ApiConfiguration): string => { |
10 | | - const description_parts = [api_configuration.model_provider_name] |
11 | | - if (api_configuration.temperature != null) { |
12 | | - description_parts.push(`${api_configuration.temperature}`) |
13 | | - } |
14 | | - if (api_configuration.reasoning_effort) { |
15 | | - description_parts.push(`${api_configuration.reasoning_effort}`) |
16 | | - } |
17 | | - return description_parts.join(' · ') |
18 | | -} |
| 6 | +import { ApiConfiguration } from '@/views/settings/types/messages' |
19 | 7 |
|
20 | 8 | export const handle_get_api_configurations = async ( |
21 | 9 | provider: SettingsProvider |
22 | 10 | ): Promise<void> => { |
23 | 11 | const providers_manager = new ModelProvidersManager(provider.context) |
24 | 12 |
|
25 | | - const saved_api_configurations = await providers_manager.get_api_configurations() |
| 13 | + const saved_api_configurations = |
| 14 | + await providers_manager.get_api_configurations() |
| 15 | + |
| 16 | + const api_configurations: ApiConfiguration[] = saved_api_configurations.map( |
| 17 | + (api_configuration) => ({ |
| 18 | + ...api_configuration, |
| 19 | + id: get_api_configuration_id(api_configuration) |
| 20 | + }) |
| 21 | + ) |
26 | 22 |
|
27 | | - const def_cac = await providers_manager.get_default_code_completions_api_configuration() |
28 | | - const def_iu = await providers_manager.get_default_intelligent_update_api_configuration() |
29 | | - const def_cm = await providers_manager.get_default_commit_messages_api_configuration() |
| 23 | + const def_cac = |
| 24 | + await providers_manager.get_default_code_completions_api_configuration() |
| 25 | + const def_iu = |
| 26 | + await providers_manager.get_default_intelligent_update_api_configuration() |
| 27 | + const def_cm = |
| 28 | + await providers_manager.get_default_commit_messages_api_configuration() |
30 | 29 | const def_frf = |
31 | 30 | await providers_manager.get_default_find_relevant_files_api_configuration() |
32 | | - const def_vi = await providers_manager.get_default_voice_input_api_configuration() |
33 | | - |
34 | | - const api_configurations_for_client: ApiConfigurationForClient[] = saved_api_configurations.map( |
35 | | - (api_configuration) => { |
36 | | - return { |
37 | | - id: get_api_configuration_id(api_configuration), |
38 | | - model: api_configuration.model, |
39 | | - description: create_description(api_configuration) |
40 | | - } |
41 | | - } |
42 | | - ) |
| 31 | + const def_vi = |
| 32 | + await providers_manager.get_default_voice_input_api_configuration() |
43 | 33 |
|
44 | 34 | provider.postMessage({ |
45 | 35 | command: 'API_CONFIGURATIONS', |
46 | | - api_configurations: api_configurations_for_client, |
| 36 | + api_configurations, |
47 | 37 | defaults: { |
48 | 38 | 'code-at-cursor': def_cac ? get_api_configuration_id(def_cac) : null, |
49 | 39 | 'intelligent-update': def_iu ? get_api_configuration_id(def_iu) : null, |
|
0 commit comments