Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly pass user selected LM for intent detection (#230014) #230028

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading