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