Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/byok/vscode-node/openAIProvider.ts
13399 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
import { IConfigurationService } from '../../../platform/configuration/common/configurationService';
6
import { IChatModelInformation, ModelSupportedEndpoint } from '../../../platform/endpoint/common/endpointProvider';
7
import { ILogService } from '../../../platform/log/common/logService';
8
import { IFetcherService } from '../../../platform/networking/common/fetcherService';
9
import { IExperimentationService } from '../../../platform/telemetry/common/nullExperimentationService';
10
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
11
import { BYOKKnownModels } from '../common/byokProvider';
12
import { AbstractOpenAICompatibleLMProvider } from './abstractLanguageModelChatProvider';
13
import { IBYOKStorageService } from './byokStorageService';
14
15
export class OAIBYOKLMProvider extends AbstractOpenAICompatibleLMProvider {
16
public static readonly providerName = 'OpenAI';
17
18
constructor(
19
knownModels: BYOKKnownModels,
20
byokStorageService: IBYOKStorageService,
21
@IFetcherService fetcherService: IFetcherService,
22
@ILogService logService: ILogService,
23
@IInstantiationService instantiationService: IInstantiationService,
24
@IConfigurationService configurationService: IConfigurationService,
25
@IExperimentationService expService: IExperimentationService
26
) {
27
super(
28
OAIBYOKLMProvider.providerName.toLowerCase(),
29
OAIBYOKLMProvider.providerName,
30
knownModels,
31
byokStorageService,
32
fetcherService,
33
logService,
34
instantiationService,
35
configurationService,
36
expService
37
);
38
}
39
40
protected override getModelsBaseUrl(): string {
41
return 'https://api.openai.com/v1';
42
}
43
44
protected override getModelInfo(modelId: string, modelUrl: string): IChatModelInformation {
45
const modelInfo = super.getModelInfo(modelId, modelUrl);
46
modelInfo.supported_endpoints = [
47
ModelSupportedEndpoint.ChatCompletions,
48
ModelSupportedEndpoint.Responses
49
];
50
return modelInfo;
51
}
52
}
53
54