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