Path: blob/main/extensions/copilot/src/extension/conversation/common/languageModelAccess.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*--------------------------------------------------------------------------------------------*/456import { IChatEndpoint, IChatEndpointTokenPricing } from '../../../platform/networking/common/networking';7import * as l10n from '@vscode/l10n';8import type { LanguageModelChatInformation } from 'vscode';910/**11* Returns a description of the model's capabilities and intended use cases.12* This is shown in the rich hover when selecting models.13*/14export function getModelCapabilitiesDescription(endpoint: IChatEndpoint | LanguageModelChatInformation): string | undefined {15const name = endpoint.name.toLowerCase();16const family = endpoint.family.toLowerCase();1718// Claude models19if (family.includes('claude') || name.includes('claude')) {20if (name.includes('opus')) {21return l10n.t('Most capable Claude model. Excellent for complex analysis, coding tasks, and nuanced creative writing.');22}23if (name.includes('sonnet')) {24return l10n.t('Balanced Claude model offering strong performance for everyday coding and chat tasks at faster speeds.');25}26if (name.includes('haiku')) {27return l10n.t('Fastest and most compact Claude model. Ideal for quick responses and simple tasks.');28}29}3031// GPT models32if (family.includes('gpt') || name.includes('gpt') || family.includes('codex') || name.includes('codex')) {33if (name.includes('codex') || family.includes('codex')) {34return l10n.t('OpenAI Codex model specialized for code generation, debugging, and software development tasks.');35}36if (name.includes('mini')) {37return l10n.t('Lightweight GPT model for quick responses and simple tasks with low latency.');38}39if (name.includes('copilot')) {40return l10n.t('GPT model fine-tuned for Copilot code completions.');41}42if (name.includes('4o')) {43return l10n.t('Optimized GPT-4 model with faster responses and multimodal capabilities.');44}45if (name.includes('4.1')) {46return l10n.t('Enhanced GPT-4 model with improved instruction following and coding performance.');47}48return l10n.t('OpenAI GPT model for coding and general assistance.');49}5051// Gemini models52if (family.includes('gemini') || name.includes('gemini')) {53if (name.includes('flash')) {54return l10n.t('Fast and efficient Gemini model optimized for quick responses and high throughput.');55}56if (name.includes('pro')) {57return l10n.t("Google's advanced Gemini Pro model with strong reasoning and coding capabilities.");58}59return l10n.t('Google Gemini model with balanced performance for coding and general assistance.');60}6162// Grok models63if (family.includes('grok') || name.includes('grok')) {64return l10n.t('xAI Grok model optimized for fast code generation and development tasks.');65}6667return undefined;68}6970function formatAicPrice(price: number): string {71if (price < 0.01) {72return price.toExponential(2);73}74// Remove unnecessary trailing zeros75return price.toFixed(4).replace(/\.?0+$/, '');76}7778/**79* Formats a compact pricing label for display in the model management column.80* Shows input and output AICs per million tokens.81*/82export function formatPricingLabel(pricing: IChatEndpointTokenPricing): string {83return l10n.t(84'In: {0} · Out: {1} AICs/1M tokens',85formatAicPrice(pricing.inputPrice),86formatAicPrice(pricing.outputPrice),87);88}899091