Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/byok/vscode-node/byokModelInfo.ts
13399 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
import { l10n, type LanguageModelChatInformation, type LanguageModelConfigurationSchema } from 'vscode';
6
import { BYOKKnownModels, byokKnownModelsToAPIInfo } from '../common/byokProvider';
7
8
/**
9
* Wraps {@link byokKnownModelsToAPIInfo} and enriches each model entry with
10
* a localized configurationSchema for the "Thinking Effort" picker when the
11
* model's capabilities include `supportsReasoningEffort`.
12
*/
13
export function byokKnownModelsToAPIInfoWithEffort(providerName: string, knownModels: BYOKKnownModels | undefined): LanguageModelChatInformation[] {
14
const models = byokKnownModelsToAPIInfo(providerName, knownModels);
15
if (!knownModels) {
16
return models;
17
}
18
19
return models.map(model => {
20
const capabilities = knownModels[model.id];
21
const effortLevels = capabilities?.supportsReasoningEffort;
22
if (!effortLevels || effortLevels.length === 0) {
23
return model;
24
}
25
return {
26
...model,
27
...buildEffortConfigurationSchema(effortLevels, model.family),
28
};
29
});
30
}
31
32
function buildEffortConfigurationSchema(effortLevels: readonly string[], family: string): { configurationSchema?: LanguageModelConfigurationSchema } {
33
const lowerFamily = family.toLowerCase();
34
const preferred = lowerFamily.startsWith('claude') ? 'high' : 'medium';
35
const defaultEffort = effortLevels.includes(preferred) ? preferred : undefined;
36
37
return {
38
configurationSchema: {
39
properties: {
40
reasoningEffort: {
41
type: 'string',
42
title: l10n.t('Thinking Effort'),
43
enum: effortLevels,
44
enumItemLabels: effortLevels.map(level => level.charAt(0).toUpperCase() + level.slice(1)),
45
enumDescriptions: effortLevels.map(level => {
46
switch (level) {
47
case 'none': return l10n.t('No reasoning applied');
48
case 'low': return l10n.t('Faster responses with less reasoning');
49
case 'medium': return l10n.t('Balanced reasoning and speed');
50
case 'high': return l10n.t('Maximum reasoning depth');
51
case 'max': return l10n.t('Absolute maximum capability with no constraints');
52
default: return level;
53
}
54
}),
55
default: defaultEffort,
56
group: 'navigation',
57
}
58
}
59
}
60
};
61
}
62
63