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