Skip to content

Commit 106df9b

Browse files
authored
Correctly pass user selected LM for intent detection (microsoft#230014)
Fix microsoft#229616
1 parent 1cbbe85 commit 106df9b

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
14541454
},
14551455
registerChatParticipantDetectionProvider(provider: vscode.ChatParticipantDetectionProvider) {
14561456
checkProposedApiEnabled(extension, 'chatParticipantAdditions');
1457-
return extHostChatAgents2.registerChatParticipantDetectionProvider(provider);
1457+
return extHostChatAgents2.registerChatParticipantDetectionProvider(extension, provider);
14581458
},
14591459
};
14601460

src/vs/workbench/api/common/extHostChatAgents2.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
285285
private readonly _proxy: MainThreadChatAgentsShape2;
286286

287287
private static _participantDetectionProviderIdPool = 0;
288-
private readonly _participantDetectionProviders = new Map<number, vscode.ChatParticipantDetectionProvider>();
288+
private readonly _participantDetectionProviders = new Map<number, ExtHostParticipantDetector>();
289289

290290
private readonly _sessionDisposables: DisposableMap<string, DisposableStore> = this._register(new DisposableMap());
291291
private readonly _completionDisposables: DisposableMap<number, DisposableStore> = this._register(new DisposableMap());
@@ -323,9 +323,9 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
323323
return agent.apiAgent;
324324
}
325325

326-
registerChatParticipantDetectionProvider(provider: vscode.ChatParticipantDetectionProvider): vscode.Disposable {
326+
registerChatParticipantDetectionProvider(extension: IExtensionDescription, provider: vscode.ChatParticipantDetectionProvider): vscode.Disposable {
327327
const handle = ExtHostChatAgents2._participantDetectionProviderIdPool++;
328-
this._participantDetectionProviders.set(handle, provider);
328+
this._participantDetectionProviders.set(handle, new ExtHostParticipantDetector(extension, provider));
329329
this._proxy.$registerChatParticipantDetectionProvider(handle);
330330
return toDisposable(() => {
331331
this._participantDetectionProviders.delete(handle);
@@ -336,13 +336,18 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
336336
async $detectChatParticipant(handle: number, requestDto: Dto<IChatAgentRequest>, context: { history: IChatAgentHistoryEntryDto[] }, options: { location: ChatAgentLocation; participants?: vscode.ChatParticipantMetadata[] }, token: CancellationToken): Promise<vscode.ChatParticipantDetectionResult | null | undefined> {
337337
const { request, location, history } = await this._createRequest(requestDto, context);
338338

339-
const provider = this._participantDetectionProviders.get(handle);
340-
if (!provider) {
339+
const detector = this._participantDetectionProviders.get(handle);
340+
if (!detector) {
341341
return undefined;
342342
}
343343

344-
return provider.provideParticipantDetection(
345-
typeConvert.ChatAgentRequest.to(request, location),
344+
const extRequest = typeConvert.ChatAgentRequest.to(request, location);
345+
if (request.userSelectedModelId && isProposedApiEnabled(detector.extension, 'chatParticipantAdditions')) {
346+
extRequest.userSelectedModel = await this._languageModels.getLanguageModelByIdentifier(detector.extension, request.userSelectedModelId);
347+
}
348+
349+
return detector.provider.provideParticipantDetection(
350+
extRequest,
346351
{ history },
347352
{ participants: options.participants, location: typeConvert.ChatLocation.to(options.location) },
348353
token
@@ -588,6 +593,13 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
588593
}
589594
}
590595

596+
class ExtHostParticipantDetector {
597+
constructor(
598+
public readonly extension: IExtensionDescription,
599+
public readonly provider: vscode.ChatParticipantDetectionProvider,
600+
) { }
601+
}
602+
591603
class ExtHostChatAgent {
592604

593605
private _followupProvider: vscode.ChatFollowupProvider | undefined;

0 commit comments

Comments
 (0)