mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-01 22:12:26 +01:00
New setting for inlinechat.defaultModel
This commit is contained in:
@@ -45,7 +45,7 @@ import { IChatService } from '../../chat/common/chatService/chatService.js';
|
||||
import { IChatRequestVariableEntry, IDiagnosticVariableEntryFilterData } from '../../chat/common/attachments/chatVariableEntries.js';
|
||||
import { isResponseVM } from '../../chat/common/model/chatViewModel.js';
|
||||
import { ChatAgentLocation } from '../../chat/common/constants.js';
|
||||
import { ILanguageModelChatSelector, ILanguageModelsService, isILanguageModelChatSelector } from '../../chat/common/languageModels.js';
|
||||
import { ILanguageModelChatMetadata, ILanguageModelChatSelector, ILanguageModelsService, isILanguageModelChatSelector } from '../../chat/common/languageModels.js';
|
||||
import { isNotebookContainingCellEditor as isNotebookWithCellEditor } from '../../notebook/browser/notebookEditor.js';
|
||||
import { INotebookEditorService } from '../../notebook/browser/services/notebookEditorService.js';
|
||||
import { CellUri, ICellEditOperation } from '../../notebook/common/notebookCommon.js';
|
||||
@@ -106,8 +106,6 @@ export class InlineChatController implements IEditorContribution {
|
||||
return editor.getContribution<InlineChatController>(InlineChatController.ID) ?? undefined;
|
||||
}
|
||||
|
||||
private static _selectVendorDefaultLanguageModel: boolean = true;
|
||||
|
||||
private readonly _store = new DisposableStore();
|
||||
private readonly _isActiveController = observableValue(this, false);
|
||||
private readonly _renderMode: IObservable<'zone' | 'hover'>;
|
||||
@@ -473,25 +471,25 @@ export class InlineChatController implements IEditorContribution {
|
||||
const session = this._inlineChatSessionService.createSession(this._editor);
|
||||
const store = new DisposableStore();
|
||||
|
||||
// fallback to the default model of the selected vendor unless an explicit selection was made for the session
|
||||
// or unless the user has chosen to persist their model choice
|
||||
const persistModelChoice = this._configurationService.getValue<boolean>(InlineChatConfigKeys.PersistModelChoice);
|
||||
const model = this._zone.value.widget.chatWidget.input.selectedLanguageModel;
|
||||
if (!persistModelChoice && InlineChatController._selectVendorDefaultLanguageModel && model && !model.metadata.isDefaultForLocation[session.chatModel.initialLocation]) {
|
||||
const ids = await this._languageModelService.selectLanguageModels({ vendor: model.metadata.vendor });
|
||||
for (const identifier of ids) {
|
||||
// Check for default model setting
|
||||
const defaultModelSetting = this._configurationService.getValue<string>(InlineChatConfigKeys.DefaultModel);
|
||||
if (defaultModelSetting) {
|
||||
// Try to find a model matching the setting
|
||||
const allModels = await this._languageModelService.selectLanguageModels({});
|
||||
let foundModel = false;
|
||||
for (const identifier of allModels) {
|
||||
const candidate = this._languageModelService.lookupLanguageModel(identifier);
|
||||
if (candidate?.isDefaultForLocation[session.chatModel.initialLocation]) {
|
||||
if (candidate && ILanguageModelChatMetadata.matchesQualifiedName(defaultModelSetting, candidate)) {
|
||||
this._zone.value.widget.chatWidget.input.setCurrentLanguageModel({ metadata: candidate, identifier });
|
||||
foundModel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundModel) {
|
||||
onUnexpectedError(new Error(`inlineChat.defaultModel setting value '${defaultModelSetting}' did not match any available model. Falling back to vendor default.`));
|
||||
}
|
||||
}
|
||||
|
||||
store.add(this._zone.value.widget.chatWidget.input.onDidChangeCurrentLanguageModel(newModel => {
|
||||
InlineChatController._selectVendorDefaultLanguageModel = Boolean(newModel.metadata.isDefaultForLocation[session.chatModel.initialLocation]);
|
||||
}));
|
||||
|
||||
// ADD diagnostics
|
||||
const entries: IChatRequestVariableEntry[] = [];
|
||||
for (const [range, marker] of this._markerDecorationsService.getLiveMarkers(uri)) {
|
||||
|
||||
Reference in New Issue
Block a user