mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-09 00:05:28 +01:00
Fix auto mode fallback for empty model providers (#316174)
Fix auto mode with empty model providers Treat an empty current model provider as no provider affinity so Auto Mode still falls back to the first available model with a known endpoint. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -403,7 +403,7 @@ export class AutomodeService extends Disposable implements IAutomodeService {
|
||||
}
|
||||
|
||||
private _selectDefaultModel(currentModelProvider: string | undefined, availableModels: string[], knownEndpoints: IChatEndpoint[]): IChatEndpoint {
|
||||
const selectedModel = (currentModelProvider && this._findSameProviderModel(currentModelProvider, availableModels, knownEndpoints))
|
||||
const selectedModel = (currentModelProvider ? this._findSameProviderModel(currentModelProvider, availableModels, knownEndpoints) : undefined)
|
||||
?? this._findFirstAvailableModel(availableModels, knownEndpoints);
|
||||
if (selectedModel) {
|
||||
return selectedModel;
|
||||
|
||||
@@ -433,6 +433,24 @@ describe('AutomodeService', () => {
|
||||
expect(secondResult).toBe(firstResult);
|
||||
});
|
||||
|
||||
it('should fall back to first available model when the current provider is empty', async () => {
|
||||
const openaiEndpoint = createEndpoint('gpt-4o', 'OpenAI');
|
||||
const chamomileEndpoint = createEndpoint('chamomile', '');
|
||||
|
||||
mockApiResponse(['chamomile'], 'token-empty-provider');
|
||||
|
||||
automodeService = createService();
|
||||
const chatRequest: Partial<ChatRequest> = {
|
||||
location: ChatLocation.Panel,
|
||||
prompt: 'test',
|
||||
sessionId: 'session-empty-provider'
|
||||
};
|
||||
|
||||
const firstResult = await automodeService.resolveAutoModeEndpoint(chatRequest as ChatRequest, [openaiEndpoint, chamomileEndpoint]);
|
||||
const secondResult = await automodeService.resolveAutoModeEndpoint(chatRequest as ChatRequest, [openaiEndpoint, chamomileEndpoint]);
|
||||
expect([firstResult.model, secondResult.model]).toEqual(['chamomile', 'chamomile']);
|
||||
});
|
||||
|
||||
it('should fall back to first known endpoint when no available models match', async () => {
|
||||
mockApiResponse(['unknown-model-1', 'unknown-model-2']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user