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