@vscode/chat-lib 0.48.2026051206 → 0.49.2026051801
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.d.ts +1 -1
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.js +17 -7
- package/dist/src/_internal/extension/byok/node/openAIEndpoint.js.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js +4 -3
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js.map +1 -1
- package/dist/src/_internal/platform/authentication/common/copilotToken.d.ts +6 -5
- package/dist/src/_internal/platform/authentication/common/copilotToken.d.ts.map +1 -1
- package/dist/src/_internal/platform/authentication/common/copilotToken.js +8 -4
- package/dist/src/_internal/platform/authentication/common/copilotToken.js.map +1 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.js +1 -1
- package/dist/src/_internal/platform/authentication/node/copilotTokenManager.js.map +1 -1
- package/dist/src/_internal/platform/chat/common/chatQuotaService.d.ts +11 -0
- package/dist/src/_internal/platform/chat/common/chatQuotaService.d.ts.map +1 -1
- package/dist/src/_internal/platform/chat/common/chatQuotaService.js.map +1 -1
- package/dist/src/_internal/platform/chat/common/chatQuotaServiceImpl.d.ts +4 -1
- package/dist/src/_internal/platform/chat/common/chatQuotaServiceImpl.d.ts.map +1 -1
- package/dist/src/_internal/platform/chat/common/chatQuotaServiceImpl.js +41 -3
- package/dist/src/_internal/platform/chat/common/chatQuotaServiceImpl.js.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.d.ts +2 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.d.ts.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.js +51 -17
- package/dist/src/_internal/platform/chat/common/commonTypes.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +20 -15
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +14 -14
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.d.ts +2 -2
- package/dist/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.js +1 -1
- package/dist/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts +3 -7
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js +17 -29
- package/dist/src/_internal/platform/endpoint/common/chatModelCapabilities.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts +1 -1
- package/dist/src/_internal/platform/endpoint/common/endpointProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts +3 -3
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js +10 -4
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.d.ts +24 -0
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.js +31 -1
- package/dist/src/_internal/platform/endpoint/node/copilotChatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts +20 -3
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js +275 -74
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/modelMetadataFetcher.d.ts +96 -0
- package/dist/src/_internal/platform/endpoint/node/modelMetadataFetcher.d.ts.map +1 -0
- package/dist/src/_internal/platform/endpoint/node/modelMetadataFetcher.js +303 -0
- package/dist/src/_internal/platform/endpoint/node/modelMetadataFetcher.js.map +1 -0
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts +7 -0
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js +163 -5
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.d.ts +3 -0
- package/dist/src/_internal/platform/github/common/githubService.d.ts.map +1 -1
- package/dist/src/_internal/platform/github/common/githubService.js +42 -13
- package/dist/src/_internal/platform/github/common/githubService.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/anthropic.d.ts +53 -1
- package/dist/src/_internal/platform/networking/common/anthropic.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/anthropic.js +76 -5
- package/dist/src/_internal/platform/networking/common/anthropic.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetch.d.ts +1 -4
- package/dist/src/_internal/platform/networking/common/fetch.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.d.ts +2 -2
- package/dist/src/_internal/platform/networking/common/networking.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/networking.js +1 -1
- package/dist/src/_internal/platform/networking/common/networking.js.map +1 -1
- package/dist/src/_internal/util/common/taskSingler.d.ts +9 -0
- package/dist/src/_internal/util/common/taskSingler.d.ts.map +1 -0
- package/dist/src/_internal/util/common/taskSingler.js +27 -0
- package/dist/src/_internal/util/common/taskSingler.js.map +1 -0
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +1 -1
- package/dist/src/main.js.map +1 -1
- package/dist/src/package.json +206 -55
- package/package.json +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { LanguageModelChat } from 'vscode';
|
|
2
|
+
import { Event } from '../../../util/vs/base/common/event';
|
|
3
|
+
import { Disposable } from '../../../util/vs/base/common/lifecycle';
|
|
4
|
+
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
|
|
5
|
+
import { IAuthenticationService } from '../../authentication/common/authentication';
|
|
6
|
+
import { IConfigurationService } from '../../configuration/common/configurationService';
|
|
7
|
+
import { IEnvService } from '../../env/common/envService';
|
|
8
|
+
import { IOctoKitService } from '../../github/common/githubService';
|
|
9
|
+
import { ILogService } from '../../log/common/logService';
|
|
10
|
+
import { IRequestLogger } from '../../requestLogger/common/requestLogger';
|
|
11
|
+
import { IExperimentationService } from '../../telemetry/common/nullExperimentationService';
|
|
12
|
+
import { IChatModelInformation, ICompletionModelInformation, IEmbeddingModelInformation } from '../common/endpointProvider';
|
|
13
|
+
export interface IModelMetadataFetcher {
|
|
14
|
+
/**
|
|
15
|
+
* Fires whenever we refresh the models from the server.
|
|
16
|
+
* Does not always indicate there is a change, just that the data is fresh
|
|
17
|
+
*/
|
|
18
|
+
onDidModelsRefresh: Event<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets all the completion models known by the model fetcher endpoint
|
|
21
|
+
*/
|
|
22
|
+
getAllCompletionModels(forceRefresh: boolean): Promise<ICompletionModelInformation[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Gets all the chat models known by the model fetcher endpoint
|
|
25
|
+
*/
|
|
26
|
+
getAllChatModels(): Promise<IChatModelInformation[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves the API-marked default Copilot utility model — the model
|
|
29
|
+
* the CAPI `/models` response flags with `is_chat_fallback === true`.
|
|
30
|
+
* Used to back the `copilot-utility` internal endpoint family.
|
|
31
|
+
*/
|
|
32
|
+
getCopilotUtilityModel(): Promise<IChatModelInformation>;
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves a chat model by its CAPI family identifier (e.g.
|
|
35
|
+
* `gpt-4o-mini`, `claude-sonnet-4`). The family must match
|
|
36
|
+
* `IChatModelCapabilities.family` of a model returned from the
|
|
37
|
+
* `/models` endpoint.
|
|
38
|
+
* @param family The CAPI family identifier of the model to fetch
|
|
39
|
+
*/
|
|
40
|
+
getChatModelFromCapiFamily(family: string): Promise<IChatModelInformation>;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves a chat model by its id
|
|
43
|
+
* @param id The id of the chat model you want to get
|
|
44
|
+
* @returns The chat model information if found, otherwise undefined
|
|
45
|
+
*/
|
|
46
|
+
getChatModelFromApiModel(model: LanguageModelChat): Promise<IChatModelInformation | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves an embeddings model by its family name
|
|
49
|
+
* @param family The family of the model to fetch
|
|
50
|
+
*/
|
|
51
|
+
getEmbeddingsModel(family: 'text-embedding-3-small'): Promise<IEmbeddingModelInformation>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Responsible for interacting with the CAPI Model API
|
|
55
|
+
* This is solely owned by the EndpointProvider (and TestEndpointProvider) which uses this service to power server side rollout of models
|
|
56
|
+
* All model acquisition should be done through the EndpointProvider
|
|
57
|
+
*/
|
|
58
|
+
export declare class ModelMetadataFetcher extends Disposable implements IModelMetadataFetcher {
|
|
59
|
+
protected readonly _isModelLab: boolean;
|
|
60
|
+
private readonly _octoKitService;
|
|
61
|
+
private readonly _requestLogger;
|
|
62
|
+
private readonly _configService;
|
|
63
|
+
private readonly _expService;
|
|
64
|
+
private readonly _envService;
|
|
65
|
+
private readonly _authService;
|
|
66
|
+
private readonly _logService;
|
|
67
|
+
private readonly _instantiationService;
|
|
68
|
+
private static readonly ALL_MODEL_KEY;
|
|
69
|
+
private _familyMap;
|
|
70
|
+
private _completionsFamilyMap;
|
|
71
|
+
private _copilotUtilityModel;
|
|
72
|
+
private _lastFetchTime;
|
|
73
|
+
private readonly _taskSingler;
|
|
74
|
+
private _lastFetchError;
|
|
75
|
+
private readonly _onDidModelRefresh;
|
|
76
|
+
onDidModelsRefresh: Event<void>;
|
|
77
|
+
constructor(_isModelLab: boolean, _octoKitService: IOctoKitService, _requestLogger: IRequestLogger, _configService: IConfigurationService, _expService: IExperimentationService, _envService: IEnvService, _authService: IAuthenticationService, _logService: ILogService, _instantiationService: IInstantiationService);
|
|
78
|
+
getAllCompletionModels(forceRefresh: boolean): Promise<ICompletionModelInformation[]>;
|
|
79
|
+
getAllChatModels(): Promise<IChatModelInformation[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Hydrates a model API response from the `/models` endpoint with proper exp overrides and error handling
|
|
82
|
+
* @param resolvedModel The resolved model to hydrate
|
|
83
|
+
* @returns The resolved model with proper exp overrides and token counts
|
|
84
|
+
*/
|
|
85
|
+
private _hydrateResolvedModel;
|
|
86
|
+
getCopilotUtilityModel(): Promise<IChatModelInformation>;
|
|
87
|
+
getChatModelFromCapiFamily(family: string): Promise<IChatModelInformation>;
|
|
88
|
+
getChatModelFromApiModel(apiModel: LanguageModelChat): Promise<IChatModelInformation | undefined>;
|
|
89
|
+
getEmbeddingsModel(family: 'text-embedding-3-small'): Promise<IEmbeddingModelInformation>;
|
|
90
|
+
private _shouldRefreshModels;
|
|
91
|
+
private _fetchModels;
|
|
92
|
+
private _getMaxPromptTokensOverride;
|
|
93
|
+
private _getErrorMessage;
|
|
94
|
+
private _getShowInModelPickerOverride;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=modelMetadataFetcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelMetadataFetcher.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/endpoint/node/modelMetadataFetcher.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAW,KAAK,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAEpE,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,CAAC;IAqBjG,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAStG,OAAO,CAAC,oBAAoB;YAuBd,YAAY;IA0D1B,OAAO,CAAC,2BAA2B;YAsCrB,gBAAgB;IAY9B,OAAO,CAAC,6BAA6B;CAWrC"}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
13
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
14
|
+
};
|
|
15
|
+
var ModelMetadataFetcher_1;
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ModelMetadataFetcher = void 0;
|
|
18
|
+
const copilot_api_1 = require("@vscode/copilot-api");
|
|
19
|
+
const taskSingler_1 = require("../../../util/common/taskSingler");
|
|
20
|
+
const event_1 = require("../../../util/vs/base/common/event");
|
|
21
|
+
const lifecycle_1 = require("../../../util/vs/base/common/lifecycle");
|
|
22
|
+
const uuid_1 = require("../../../util/vs/base/common/uuid");
|
|
23
|
+
const instantiation_1 = require("../../../util/vs/platform/instantiation/common/instantiation");
|
|
24
|
+
const authentication_1 = require("../../authentication/common/authentication");
|
|
25
|
+
const configurationService_1 = require("../../configuration/common/configurationService");
|
|
26
|
+
const envService_1 = require("../../env/common/envService");
|
|
27
|
+
const githubService_1 = require("../../github/common/githubService");
|
|
28
|
+
const logService_1 = require("../../log/common/logService");
|
|
29
|
+
const networking_1 = require("../../networking/common/networking");
|
|
30
|
+
const requestLogger_1 = require("../../requestLogger/common/requestLogger");
|
|
31
|
+
const nullExperimentationService_1 = require("../../telemetry/common/nullExperimentationService");
|
|
32
|
+
const endpointProvider_1 = require("../common/endpointProvider");
|
|
33
|
+
/**
|
|
34
|
+
* Responsible for interacting with the CAPI Model API
|
|
35
|
+
* This is solely owned by the EndpointProvider (and TestEndpointProvider) which uses this service to power server side rollout of models
|
|
36
|
+
* All model acquisition should be done through the EndpointProvider
|
|
37
|
+
*/
|
|
38
|
+
let ModelMetadataFetcher = class ModelMetadataFetcher extends lifecycle_1.Disposable {
|
|
39
|
+
static { ModelMetadataFetcher_1 = this; }
|
|
40
|
+
static { this.ALL_MODEL_KEY = 'allModels'; }
|
|
41
|
+
constructor(_isModelLab, _octoKitService, _requestLogger, _configService, _expService, _envService, _authService, _logService, _instantiationService) {
|
|
42
|
+
super();
|
|
43
|
+
this._isModelLab = _isModelLab;
|
|
44
|
+
this._octoKitService = _octoKitService;
|
|
45
|
+
this._requestLogger = _requestLogger;
|
|
46
|
+
this._configService = _configService;
|
|
47
|
+
this._expService = _expService;
|
|
48
|
+
this._envService = _envService;
|
|
49
|
+
this._authService = _authService;
|
|
50
|
+
this._logService = _logService;
|
|
51
|
+
this._instantiationService = _instantiationService;
|
|
52
|
+
this._familyMap = new Map();
|
|
53
|
+
this._completionsFamilyMap = new Map();
|
|
54
|
+
this._lastFetchTime = 0;
|
|
55
|
+
this._taskSingler = new taskSingler_1.TaskSingler();
|
|
56
|
+
this._onDidModelRefresh = new event_1.Emitter();
|
|
57
|
+
this.onDidModelsRefresh = this._onDidModelRefresh.event;
|
|
58
|
+
this._register(this._authService.onDidAuthenticationChange(() => {
|
|
59
|
+
// Auth changed so next fetch should be forced to get a new list
|
|
60
|
+
// Only clear the family map if the copilot token is undefined, as this means the user has logged out and we should clear the models, otherwise we want to keep the old models around until we get a new list
|
|
61
|
+
if (this._authService.copilotToken === undefined) {
|
|
62
|
+
this._familyMap.clear();
|
|
63
|
+
}
|
|
64
|
+
this._completionsFamilyMap.clear();
|
|
65
|
+
this._lastFetchTime = 0;
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
async getAllCompletionModels(forceRefresh) {
|
|
69
|
+
await this._taskSingler.getOrCreate(ModelMetadataFetcher_1.ALL_MODEL_KEY, () => this._fetchModels(forceRefresh));
|
|
70
|
+
const completionModels = [];
|
|
71
|
+
for (const [, models] of this._completionsFamilyMap) {
|
|
72
|
+
for (const model of models) {
|
|
73
|
+
if ((0, endpointProvider_1.isCompletionModelInformation)(model)) {
|
|
74
|
+
completionModels.push(model);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return completionModels;
|
|
79
|
+
}
|
|
80
|
+
async getAllChatModels() {
|
|
81
|
+
await this._taskSingler.getOrCreate(ModelMetadataFetcher_1.ALL_MODEL_KEY, this._fetchModels.bind(this));
|
|
82
|
+
const chatModels = [];
|
|
83
|
+
for (const [, models] of this._familyMap) {
|
|
84
|
+
for (const model of models) {
|
|
85
|
+
if ((0, endpointProvider_1.isChatModelInformation)(model)) {
|
|
86
|
+
chatModels.push(model);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return chatModels;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Hydrates a model API response from the `/models` endpoint with proper exp overrides and error handling
|
|
94
|
+
* @param resolvedModel The resolved model to hydrate
|
|
95
|
+
* @returns The resolved model with proper exp overrides and token counts
|
|
96
|
+
*/
|
|
97
|
+
async _hydrateResolvedModel(resolvedModel) {
|
|
98
|
+
if (!resolvedModel) {
|
|
99
|
+
throw this._lastFetchError ?? new Error(await this._getErrorMessage('Unable to resolve model'));
|
|
100
|
+
}
|
|
101
|
+
// If it's a chat model, update max prompt tokens based on settings + exp
|
|
102
|
+
if ((0, endpointProvider_1.isChatModelInformation)(resolvedModel) && (resolvedModel.capabilities.limits)) {
|
|
103
|
+
resolvedModel.capabilities.limits.max_prompt_tokens = this._getMaxPromptTokensOverride(resolvedModel);
|
|
104
|
+
// Also ensure prompt tokens + output tokens <= context window. Output tokens is capped to max 15% input tokens
|
|
105
|
+
const outputTokens = Math.floor(Math.min(resolvedModel.capabilities.limits.max_output_tokens ?? 4096, resolvedModel.capabilities.limits.max_prompt_tokens * 0.15));
|
|
106
|
+
const contextWindow = resolvedModel.capabilities.limits.max_context_window_tokens ?? (outputTokens + resolvedModel.capabilities.limits.max_prompt_tokens);
|
|
107
|
+
resolvedModel.capabilities.limits.max_prompt_tokens = Math.min(resolvedModel.capabilities.limits.max_prompt_tokens, contextWindow - outputTokens);
|
|
108
|
+
}
|
|
109
|
+
// If it's a chat model, update showInModelPicker based on experiment overrides
|
|
110
|
+
if ((0, endpointProvider_1.isChatModelInformation)(resolvedModel)) {
|
|
111
|
+
resolvedModel.model_picker_enabled = this._getShowInModelPickerOverride(resolvedModel);
|
|
112
|
+
}
|
|
113
|
+
if (resolvedModel.preview && !resolvedModel.name.endsWith('(Preview)')) {
|
|
114
|
+
// If the model is a preview model, we append (Preview) to the name
|
|
115
|
+
resolvedModel.name = `${resolvedModel.name} (Preview)`;
|
|
116
|
+
}
|
|
117
|
+
return resolvedModel;
|
|
118
|
+
}
|
|
119
|
+
async getCopilotUtilityModel() {
|
|
120
|
+
await this._taskSingler.getOrCreate(ModelMetadataFetcher_1.ALL_MODEL_KEY, this._fetchModels.bind(this));
|
|
121
|
+
const resolvedModel = this._copilotUtilityModel;
|
|
122
|
+
if (!resolvedModel || !(0, endpointProvider_1.isChatModelInformation)(resolvedModel)) {
|
|
123
|
+
throw new Error(await this._getErrorMessage('Unable to resolve Copilot utility chat model (server did not mark a chat fallback model)'));
|
|
124
|
+
}
|
|
125
|
+
return resolvedModel;
|
|
126
|
+
}
|
|
127
|
+
async getChatModelFromCapiFamily(family) {
|
|
128
|
+
await this._taskSingler.getOrCreate(ModelMetadataFetcher_1.ALL_MODEL_KEY, this._fetchModels.bind(this));
|
|
129
|
+
const resolvedModel = this._familyMap.get(family)?.[0];
|
|
130
|
+
if (!resolvedModel || !(0, endpointProvider_1.isChatModelInformation)(resolvedModel)) {
|
|
131
|
+
throw new Error(await this._getErrorMessage(`Unable to resolve chat model with CAPI family selection: ${family}`));
|
|
132
|
+
}
|
|
133
|
+
return resolvedModel;
|
|
134
|
+
}
|
|
135
|
+
async getChatModelFromApiModel(apiModel) {
|
|
136
|
+
await this._taskSingler.getOrCreate(ModelMetadataFetcher_1.ALL_MODEL_KEY, this._fetchModels.bind(this));
|
|
137
|
+
let resolvedModel;
|
|
138
|
+
for (const models of this._familyMap.values()) {
|
|
139
|
+
resolvedModel = models.find(model => model.id === apiModel.id &&
|
|
140
|
+
model.version === apiModel.version &&
|
|
141
|
+
model.capabilities.family === apiModel.family);
|
|
142
|
+
if (resolvedModel) {
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (!resolvedModel) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (!(0, endpointProvider_1.isChatModelInformation)(resolvedModel)) {
|
|
150
|
+
throw new Error(await this._getErrorMessage(`Unable to resolve chat model: ${apiModel.id},${apiModel.name},${apiModel.version},${apiModel.family}`));
|
|
151
|
+
}
|
|
152
|
+
return resolvedModel;
|
|
153
|
+
}
|
|
154
|
+
async getEmbeddingsModel(family) {
|
|
155
|
+
await this._taskSingler.getOrCreate(ModelMetadataFetcher_1.ALL_MODEL_KEY, this._fetchModels.bind(this));
|
|
156
|
+
const resolvedModel = this._familyMap.get(family)?.[0];
|
|
157
|
+
if (!resolvedModel || !(0, endpointProvider_1.isEmbeddingModelInformation)(resolvedModel)) {
|
|
158
|
+
throw new Error(await this._getErrorMessage(`Unable to resolve embeddings model with family selection: ${family}`));
|
|
159
|
+
}
|
|
160
|
+
return resolvedModel;
|
|
161
|
+
}
|
|
162
|
+
_shouldRefreshModels() {
|
|
163
|
+
if (this._familyMap.size === 0) {
|
|
164
|
+
// Always refresh if we have no models as this means the last fetch failed in some way
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
const tenMinutes = 10 * 60 * 1000; // 10 minutes in milliseconds
|
|
168
|
+
const now = Date.now();
|
|
169
|
+
if (!this._lastFetchTime) {
|
|
170
|
+
return true; // If there's no last fetch time, we should refresh
|
|
171
|
+
}
|
|
172
|
+
// Only fetch if the current session is active.
|
|
173
|
+
// This avoids unnecessary network calls when VS Code is in the background.
|
|
174
|
+
if (!this._envService.isActive) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
const timeSinceLastFetch = now - this._lastFetchTime;
|
|
178
|
+
return timeSinceLastFetch > tenMinutes;
|
|
179
|
+
}
|
|
180
|
+
async _fetchModels(force) {
|
|
181
|
+
if (!force && !this._shouldRefreshModels()) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const requestStartTime = Date.now();
|
|
185
|
+
const copilotToken = (await this._authService.getCopilotToken()).token;
|
|
186
|
+
const requestId = (0, uuid_1.generateUuid)();
|
|
187
|
+
const requestMetadata = { type: copilot_api_1.RequestType.Models, isModelLab: this._isModelLab };
|
|
188
|
+
try {
|
|
189
|
+
const response = await this._instantiationService.invokeFunction(networking_1.getRequest, {
|
|
190
|
+
endpointOrUrl: requestMetadata,
|
|
191
|
+
secretKey: copilotToken,
|
|
192
|
+
intent: 'model-access',
|
|
193
|
+
requestId,
|
|
194
|
+
});
|
|
195
|
+
this._lastFetchTime = Date.now();
|
|
196
|
+
this._logService.info(`Fetched model metadata in ${Date.now() - requestStartTime}ms ${requestId}`);
|
|
197
|
+
if (response.status < 200 || response.status >= 300) {
|
|
198
|
+
// If we're rate limited and have models, we should just return
|
|
199
|
+
if (response.status === 429 && this._familyMap.size > 0) {
|
|
200
|
+
this._logService.warn(`Rate limited while fetching models ${requestId}`);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
throw new Error(await this._getErrorMessage(`Failed to fetch models (${requestId}): ${(await response.text()) || response.statusText || `HTTP ${response.status}`}`));
|
|
204
|
+
}
|
|
205
|
+
this._familyMap.clear();
|
|
206
|
+
const data = (await response.json()).data;
|
|
207
|
+
this._requestLogger.logModelListCall(requestId, requestMetadata, data);
|
|
208
|
+
for (let model of data) {
|
|
209
|
+
model = await this._hydrateResolvedModel(model);
|
|
210
|
+
const isCompletionModel = (0, endpointProvider_1.isCompletionModelInformation)(model);
|
|
211
|
+
// The utility model is whatever model is deemed "fallback" by the server
|
|
212
|
+
if (model.is_chat_fallback && !isCompletionModel) {
|
|
213
|
+
this._copilotUtilityModel = model;
|
|
214
|
+
}
|
|
215
|
+
const family = model.capabilities.family;
|
|
216
|
+
const familyMap = isCompletionModel ? this._completionsFamilyMap : this._familyMap;
|
|
217
|
+
if (!familyMap.has(family)) {
|
|
218
|
+
familyMap.set(family, []);
|
|
219
|
+
}
|
|
220
|
+
familyMap.get(family)?.push(model);
|
|
221
|
+
}
|
|
222
|
+
this._lastFetchError = undefined;
|
|
223
|
+
this._onDidModelRefresh.fire();
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
this._logService.error(e, `Failed to fetch models (${requestId})`);
|
|
227
|
+
this._lastFetchError = e;
|
|
228
|
+
this._lastFetchTime = 0;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// get ChatMaxNumTokens from config for experimentation
|
|
232
|
+
_getMaxPromptTokensOverride(chatModelInfo) {
|
|
233
|
+
// check debug override ChatMaxTokenNum
|
|
234
|
+
const chatMaxTokenNumOverride = this._configService.getConfig(configurationService_1.ConfigKey.TeamInternal.DebugOverrideChatMaxTokenNum); // can only be set by internal users
|
|
235
|
+
// Base 3 tokens for each OpenAI completion
|
|
236
|
+
let modelLimit = -3;
|
|
237
|
+
// if option is set, takes precedence over any other logic
|
|
238
|
+
if (chatMaxTokenNumOverride > 0) {
|
|
239
|
+
modelLimit += chatMaxTokenNumOverride;
|
|
240
|
+
return modelLimit;
|
|
241
|
+
}
|
|
242
|
+
let experimentalOverrides = {};
|
|
243
|
+
try {
|
|
244
|
+
const expValue = this._expService.getTreatmentVariable('copilotchat.contextWindows');
|
|
245
|
+
experimentalOverrides = JSON.parse(expValue ?? '{}');
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
// If the experiment service either is not available or returns a bad value we ignore the overrides
|
|
249
|
+
}
|
|
250
|
+
// If there's an experiment that takes precedence over what comes back from CAPI
|
|
251
|
+
if (experimentalOverrides[chatModelInfo.id]) {
|
|
252
|
+
modelLimit += experimentalOverrides[chatModelInfo.id];
|
|
253
|
+
return modelLimit;
|
|
254
|
+
}
|
|
255
|
+
// Check if CAPI has prompt token limits and return those
|
|
256
|
+
if (chatModelInfo.capabilities?.limits?.max_prompt_tokens) {
|
|
257
|
+
modelLimit += chatModelInfo.capabilities.limits.max_prompt_tokens;
|
|
258
|
+
return modelLimit;
|
|
259
|
+
}
|
|
260
|
+
else if (chatModelInfo.capabilities.limits?.max_context_window_tokens) {
|
|
261
|
+
// Otherwise return the context window as the prompt tokens for cases where CAPI doesn't configure the prompt tokens
|
|
262
|
+
modelLimit += chatModelInfo.capabilities.limits.max_context_window_tokens;
|
|
263
|
+
return modelLimit;
|
|
264
|
+
}
|
|
265
|
+
return modelLimit;
|
|
266
|
+
}
|
|
267
|
+
async _getErrorMessage(fallback) {
|
|
268
|
+
try {
|
|
269
|
+
const status = await this._octoKitService.getGitHubOutageStatus();
|
|
270
|
+
if (status !== 0 /* GitHubOutageStatus.None */) {
|
|
271
|
+
return 'Error fetching models! It appears that GitHub is experiencing an outage. Please check the [GitHub Status Page](https://githubstatus.com) for more info';
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
// Don't let status check failures block the original error
|
|
276
|
+
}
|
|
277
|
+
return fallback;
|
|
278
|
+
}
|
|
279
|
+
_getShowInModelPickerOverride(resolvedModel) {
|
|
280
|
+
let modelPickerOverrides = {};
|
|
281
|
+
const expResult = this._expService.getTreatmentVariable('copilotchat.showInModelPicker');
|
|
282
|
+
try {
|
|
283
|
+
modelPickerOverrides = JSON.parse(expResult || '{}');
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
// No-op if parsing experiment fails
|
|
287
|
+
}
|
|
288
|
+
return modelPickerOverrides[resolvedModel.id] ?? resolvedModel.model_picker_enabled;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
exports.ModelMetadataFetcher = ModelMetadataFetcher;
|
|
292
|
+
exports.ModelMetadataFetcher = ModelMetadataFetcher = ModelMetadataFetcher_1 = __decorate([
|
|
293
|
+
__param(1, githubService_1.IOctoKitService),
|
|
294
|
+
__param(2, requestLogger_1.IRequestLogger),
|
|
295
|
+
__param(3, configurationService_1.IConfigurationService),
|
|
296
|
+
__param(4, nullExperimentationService_1.IExperimentationService),
|
|
297
|
+
__param(5, envService_1.IEnvService),
|
|
298
|
+
__param(6, authentication_1.IAuthenticationService),
|
|
299
|
+
__param(7, logService_1.ILogService),
|
|
300
|
+
__param(8, instantiation_1.IInstantiationService)
|
|
301
|
+
], ModelMetadataFetcher);
|
|
302
|
+
//#endregion
|
|
303
|
+
//# sourceMappingURL=modelMetadataFetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelMetadataFetcher.js","sourceRoot":"","sources":["../../../../../../src/_internal/platform/endpoint/node/modelMetadataFetcher.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;AAEhG,qDAAmE;AAEnE,kEAA+D;AAC/D,8DAAoE;AACpE,sEAAoE;AACpE,4DAAiE;AACjE,gGAAqG;AAErG,+EAAo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;YACJ,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;QACtD,CAAC;QAAC,MAAM,CAAC;YACR,oCAAoC;QACrC,CAAC;QAED,OAAO,oBAAoB,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,aAAa,CAAC,oBAAoB,CAAC;IACrF,CAAC;;AA7RW,oDAAoB;+BAApB,oBAAoB;IAgB9B,WAAA,+BAAe,CAAA;IACf,WAAA,8BAAc,CAAA;IACd,WAAA,4CAAqB,CAAA;IACrB,WAAA,oDAAuB,CAAA;IACvB,WAAA,wBAAW,CAAA;IACX,WAAA,uCAAsB,CAAA;IACtB,WAAA,wBAAW,CAAA;IACX,WAAA,qCAAqB,CAAA;GAvBX,oBAAoB,CA8RhC;AAED,YAAY"}
|
|
@@ -41,5 +41,12 @@ export declare class OpenAIResponsesProcessor {
|
|
|
41
41
|
private getCompactionItemsInChunk;
|
|
42
42
|
private captureCompactionItem;
|
|
43
43
|
push(chunk: OpenAI.Responses.ResponseStreamEvent, _onProgress: FinishedCallback): ChatCompletion | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Build a {@link ChatCompletion} for a terminal Responses API event other than
|
|
46
|
+
* `response.completed` (i.e. `response.incomplete` or `response.failed`). The
|
|
47
|
+
* resulting completion is fed into the same downstream switch as a normal
|
|
48
|
+
* completion so callers can map it to the appropriate user-facing error.
|
|
49
|
+
*/
|
|
50
|
+
private buildTerminalCompletion;
|
|
44
51
|
}
|
|
45
52
|
//# sourceMappingURL=responsesApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responsesApi.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/endpoint/node/responsesApi.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MA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