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