Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/extension/byok/node/test/openAIEndpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ describe('OpenAIEndpoint - Reasoning Properties', () => {

describe('CAPI mode (useResponsesApi = false)', () => {
it('should set cot_id and cot_summary properties when processing thinking content', () => {
accessor.get(IConfigurationService).setConfig(ConfigKey.UseResponsesApi, false);
const endpoint = instaService.createInstance(OpenAIEndpoint,
modelMetadata,
{
...modelMetadata,
supported_endpoints: [ModelSupportedEndpoint.ChatCompletions]
},
'test-api-key',
'https://api.openai.com/v1/chat/completions');

Expand All @@ -105,9 +107,11 @@ describe('OpenAIEndpoint - Reasoning Properties', () => {
});

it('should handle multiple messages with thinking content', () => {
accessor.get(IConfigurationService).setConfig(ConfigKey.UseResponsesApi, false);
const endpoint = instaService.createInstance(OpenAIEndpoint,
modelMetadata,
{
...modelMetadata,
supported_endpoints: [ModelSupportedEndpoint.ChatCompletions]
},
'test-api-key',
'https://api.openai.com/v1/chat/completions');

Expand Down Expand Up @@ -136,7 +140,6 @@ describe('OpenAIEndpoint - Reasoning Properties', () => {

describe('Responses API mode (useResponsesApi = true)', () => {
it('should preserve reasoning object when thinking is supported', () => {
accessor.get(IConfigurationService).setConfig(ConfigKey.UseResponsesApi, true);
accessor.get(IConfigurationService).setConfig(ConfigKey.ResponsesApiReasoningEffort, 'medium');
accessor.get(IConfigurationService).setConfig(ConfigKey.ResponsesApiReasoningSummary, 'detailed');
const endpoint = instaService.createInstance(OpenAIEndpoint,
Expand Down Expand Up @@ -167,7 +170,6 @@ describe('OpenAIEndpoint - Reasoning Properties', () => {
}
};

accessor.get(IConfigurationService).setConfig(ConfigKey.UseResponsesApi, true);
accessor.get(IConfigurationService).setConfig(ConfigKey.ResponsesApiReasoningEffort, 'medium');
accessor.get(IConfigurationService).setConfig(ConfigKey.ResponsesApiReasoningSummary, 'detailed');
const endpoint = instaService.createInstance(OpenAIEndpoint,
Expand Down
15 changes: 4 additions & 11 deletions src/extension/byok/vscode-node/openAIProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ConfigKey, IConfigurationService } from '../../../platform/configuration/common/configurationService';
import { IChatModelInformation, ModelSupportedEndpoint } from '../../../platform/endpoint/common/endpointProvider';
import { ILogService } from '../../../platform/log/common/logService';
import { IFetcherService } from '../../../platform/networking/common/fetcherService';
import { IExperimentationService } from '../../../platform/telemetry/common/nullExperimentationService';
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
import { BYOKAuthType, BYOKKnownModels, BYOKModelCapabilities } from '../common/byokProvider';
import { BaseOpenAICompatibleLMProvider } from './baseOpenAICompatibleProvider';
Expand All @@ -21,8 +19,6 @@ export class OAIBYOKLMProvider extends BaseOpenAICompatibleLMProvider {
@IFetcherService _fetcherService: IFetcherService,
@ILogService _logService: ILogService,
@IInstantiationService _instantiationService: IInstantiationService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IExperimentationService private readonly _expService: IExperimentationService
) {
super(
BYOKAuthType.GlobalApiKey,
Expand All @@ -38,13 +34,10 @@ export class OAIBYOKLMProvider extends BaseOpenAICompatibleLMProvider {

protected override async getModelInfo(modelId: string, apiKey: string | undefined, modelCapabilities?: BYOKModelCapabilities): Promise<IChatModelInformation> {
const modelInfo = await super.getModelInfo(modelId, apiKey, modelCapabilities);
const enableResponsesApi = this._configurationService.getExperimentBasedConfig(ConfigKey.UseResponsesApi, this._expService);
if (enableResponsesApi) {
modelInfo.supported_endpoints = [
ModelSupportedEndpoint.ChatCompletions,
ModelSupportedEndpoint.Responses
];
}
modelInfo.supported_endpoints = [
ModelSupportedEndpoint.ChatCompletions,
ModelSupportedEndpoint.Responses
];

return modelInfo;
}
Expand Down
3 changes: 1 addition & 2 deletions src/platform/endpoint/node/chatEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ export class ChatEndpoint implements IChatEndpoint {
return true;
}

const enableResponsesApi = this._configurationService.getExperimentBasedConfig(ConfigKey.UseResponsesApi, this._expService);
return !!(enableResponsesApi && this.modelMetadata.supported_endpoints?.includes(ModelSupportedEndpoint.Responses));
return !!this.modelMetadata.supported_endpoints?.includes(ModelSupportedEndpoint.Responses);
}

protected get useMessagesApi(): boolean {
Expand Down
6 changes: 1 addition & 5 deletions src/platform/endpoint/test/node/openaiCompatibleEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TokenizerType } from '../../../../util/common/tokenizer';
import { IInstantiationService } from '../../../../util/vs/platform/instantiation/common/instantiation';
import { IAuthenticationService } from '../../../authentication/common/authentication';
import { IChatMLFetcher } from '../../../chat/common/chatMLFetcher';
import { ConfigKey, IConfigurationService } from '../../../configuration/common/configurationService';
import { IConfigurationService } from '../../../configuration/common/configurationService';
import { IEnvService } from '../../../env/common/envService';
import { ILogService } from '../../../log/common/logService';
import { isOpenAiFunctionTool } from '../../../networking/common/fetch';
Expand Down Expand Up @@ -119,10 +119,6 @@ export class OpenAICompatibleTestEndpoint extends ChatEndpoint {
? modelConfig.supported_endpoints
: [ModelSupportedEndpoint.ChatCompletions]
};
// configurationService.useResponsesApi should be set to true if ModelSupportedEndpoint.Responses is in modelConfig.supported_endpoints
if (modelInfo.supported_endpoints?.includes(ModelSupportedEndpoint.Responses)) {
configurationService.setConfig(ConfigKey.UseResponsesApi, true);
}

super(
modelInfo,
Expand Down