Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/endpoint/node/proxyInstantApplyShortEndpoint.ts
13400 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
import { RequestMetadata, RequestType } from '@vscode/copilot-api';
7
import { TokenizerType } from '../../../util/common/tokenizer';
8
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
9
import { IAuthenticationService } from '../../authentication/common/authentication';
10
import { IChatMLFetcher } from '../../chat/common/chatMLFetcher';
11
import { ConfigKey, IConfigurationService } from '../../configuration/common/configurationService';
12
import { ILogService } from '../../log/common/logService';
13
import { IFetcherService } from '../../networking/common/fetcherService';
14
import { IChatWebSocketManager } from '../../networking/node/chatWebSocketManager';
15
import { IProxyModelsService } from '../../proxyModels/common/proxyModelsService';
16
import { IExperimentationService } from '../../telemetry/common/nullExperimentationService';
17
import { ITelemetryService } from '../../telemetry/common/telemetry';
18
import { ITokenizerProvider } from '../../tokenizer/node/tokenizer';
19
import { ICAPIClientService } from '../common/capiClient';
20
import { IDomainService } from '../common/domainService';
21
import { IChatModelInformation } from '../common/endpointProvider';
22
import { ChatEndpoint } from './chatEndpoint';
23
import { getInstantApplyModel } from './proxyModelHelper';
24
25
export class ProxyInstantApplyShortEndpoint extends ChatEndpoint {
26
27
constructor(
28
@IDomainService domainService: IDomainService,
29
@ICAPIClientService capiClientService: ICAPIClientService,
30
@IFetcherService fetcherService: IFetcherService,
31
@ITelemetryService telemetryService: ITelemetryService,
32
@IAuthenticationService private readonly authService: IAuthenticationService,
33
@IChatMLFetcher chatMLFetcher: IChatMLFetcher,
34
@ITokenizerProvider tokenizerProvider: ITokenizerProvider,
35
@IInstantiationService instantiationService: IInstantiationService,
36
@IConfigurationService configurationService: IConfigurationService,
37
@IExperimentationService experimentationService: IExperimentationService,
38
@IChatWebSocketManager chatWebSocketService: IChatWebSocketManager,
39
@ILogService logService: ILogService,
40
@IProxyModelsService proxyModelsService: IProxyModelsService,
41
) {
42
const model = getInstantApplyModel(
43
configurationService,
44
experimentationService,
45
proxyModelsService,
46
ConfigKey.Advanced.InstantApplyShortModelName,
47
);
48
const modelInfo: IChatModelInformation = {
49
id: model,
50
name: model,
51
vendor: model,
52
version: 'unknown',
53
model_picker_enabled: false,
54
is_chat_default: false,
55
is_chat_fallback: false,
56
capabilities: {
57
type: 'chat',
58
family: model,
59
tokenizer: TokenizerType.O200K,
60
supports: { streaming: true, parallel_tool_calls: false, tool_calls: false, vision: false, prediction: true },
61
limits: {
62
max_prompt_tokens: 128000,
63
max_output_tokens: 16000,
64
}
65
}
66
};
67
super(
68
modelInfo,
69
domainService,
70
chatMLFetcher,
71
tokenizerProvider,
72
instantiationService,
73
configurationService,
74
experimentationService,
75
chatWebSocketService,
76
logService
77
);
78
}
79
80
public override getExtraHeaders(): Record<string, string> {
81
const headers: Record<string, string> = {};
82
if (this.authService.speculativeDecodingEndpointToken) {
83
headers['Copilot-Edits-Session'] = this.authService.speculativeDecodingEndpointToken;
84
}
85
return headers;
86
}
87
88
override get urlOrRequestMetadata(): RequestMetadata {
89
return { type: RequestType.ProxyChatCompletions };
90
}
91
}
92
93