Skip to content

Commit 8195be9

Browse files
authored
conversation: allow 'auto' sampling endpoint through LM API (#4240)
* conversation: allow 'auto' sampling endpoint through LM API - Adds a _getEndpointForModel private method to resolve the endpoint for a model, with special handling for the AutoChatEndpoint pseudo model. This ensures the 'auto' endpoint can be properly resolved when accessed through the Language Model API. - When the model is the auto endpoint, it uses the automode service to resolve to the appropriate concrete endpoint from the available options. Fixes #299336 (Commit message generated by Copilot) * bump ci
1 parent 7524137 commit 8195be9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/extension/conversation/vscode-node/languageModelAccess.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,22 @@ export class LanguageModelAccess extends Disposable implements IExtensionContrib
313313
return models;
314314
}
315315

316+
private async _getEndpointForModel(model: vscode.LanguageModelChatInformation) {
317+
if (model.id === AutoChatEndpoint.pseudoModelId) {
318+
const allEndpoints = await this._endpointProvider.getAllChatEndpoints();
319+
return await this._automodeService.resolveAutoModeEndpoint(undefined, allEndpoints);
320+
}
321+
return this._chatEndpoints.find(e => e.model === ModelAliasRegistry.resolveAlias(model.id));
322+
}
323+
316324
private async _provideLanguageModelChatResponse(
317325
model: vscode.LanguageModelChatInformation,
318326
messages: Array<vscode.LanguageModelChatMessage | vscode.LanguageModelChatMessage2>,
319327
options: vscode.ProvideLanguageModelChatResponseOptions,
320328
progress: vscode.Progress<vscode.LanguageModelResponsePart2>,
321329
token: vscode.CancellationToken
322330
): Promise<void> {
323-
const endpoint = this._chatEndpoints.find(e => e.model === ModelAliasRegistry.resolveAlias(model.id));
331+
const endpoint = await this._getEndpointForModel(model);
324332
if (!endpoint) {
325333
throw new Error(`Endpoint not found for model ${model.id}`);
326334
}
@@ -336,7 +344,7 @@ export class LanguageModelAccess extends Disposable implements IExtensionContrib
336344
text: string | vscode.LanguageModelChatMessage | vscode.LanguageModelChatMessage2,
337345
token: vscode.CancellationToken
338346
): Promise<number> {
339-
const endpoint = this._chatEndpoints.find(e => e.model === ModelAliasRegistry.resolveAlias(model.id));
347+
const endpoint = await this._getEndpointForModel(model);
340348
if (!endpoint) {
341349
throw new Error(`Endpoint not found for model ${model.id}`);
342350
}

0 commit comments

Comments
 (0)