Skip to content

Commit

Permalink
Correctly pass user selected LM for intent detection
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Sep 27, 2024
1 parent 1cbbe85 commit e7f039a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
},
registerChatParticipantDetectionProvider(provider: vscode.ChatParticipantDetectionProvider) {
checkProposedApiEnabled(extension, 'chatParticipantAdditions');
return extHostChatAgents2.registerChatParticipantDetectionProvider(provider);
return extHostChatAgents2.registerChatParticipantDetectionProvider(extension, provider);
},
};

Expand Down
26 changes: 19 additions & 7 deletions src/vs/workbench/api/common/extHostChatAgents2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
private readonly _proxy: MainThreadChatAgentsShape2;

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

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

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

const provider = this._participantDetectionProviders.get(handle);
if (!provider) {
const detector = this._participantDetectionProviders.get(handle);
if (!detector) {
return undefined;
}

return provider.provideParticipantDetection(
typeConvert.ChatAgentRequest.to(request, location),
const extRequest = typeConvert.ChatAgentRequest.to(request, location);
if (request.userSelectedModelId && isProposedApiEnabled(detector.extension, 'chatParticipantAdditions')) {
extRequest.userSelectedModel = await this._languageModels.getLanguageModelByIdentifier(detector.extension, request.userSelectedModelId);
}

return detector.provider.provideParticipantDetection(
extRequest,
{ history },
{ participants: options.participants, location: typeConvert.ChatLocation.to(options.location) },
token
Expand Down Expand Up @@ -588,6 +593,13 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
}
}

class ExtHostParticipantDetector {
constructor(
public readonly extension: IExtensionDescription,
public readonly provider: vscode.ChatParticipantDetectionProvider,
) { }
}

class ExtHostChatAgent {

private _followupProvider: vscode.ChatFollowupProvider | undefined;
Expand Down

0 comments on commit e7f039a

Please sign in to comment.