mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 12:33:35 +01:00
Add id to chat request (#243239)
* Add id to chat request * Support proposed api check * Do some casting
This commit is contained in:
@@ -404,7 +404,8 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
|
|||||||
const { request, location, history } = await this._createRequest(requestDto, context, detector.extension);
|
const { request, location, history } = await this._createRequest(requestDto, context, detector.extension);
|
||||||
|
|
||||||
const model = await this.getModelForRequest(request, detector.extension);
|
const model = await this.getModelForRequest(request, detector.extension);
|
||||||
const extRequest = typeConvert.ChatAgentRequest.to(request, location, model, this.getDiagnosticsWhenEnabled(detector.extension));
|
const includeInteractionId = isProposedApiEnabled(detector.extension, 'chatParticipantPrivate');
|
||||||
|
const extRequest = typeConvert.ChatAgentRequest.to(includeInteractionId ? request : { ...request, requestId: '' }, location, model, this.getDiagnosticsWhenEnabled(detector.extension));
|
||||||
|
|
||||||
return detector.provider.provideParticipantDetection(
|
return detector.provider.provideParticipantDetection(
|
||||||
extRequest,
|
extRequest,
|
||||||
@@ -488,7 +489,8 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
|
|||||||
stream = new ChatAgentResponseStream(agent.extension, request, this._proxy, this._commands.converter, sessionDisposables);
|
stream = new ChatAgentResponseStream(agent.extension, request, this._proxy, this._commands.converter, sessionDisposables);
|
||||||
|
|
||||||
const model = await this.getModelForRequest(request, agent.extension);
|
const model = await this.getModelForRequest(request, agent.extension);
|
||||||
const extRequest = typeConvert.ChatAgentRequest.to(request, location, model, this.getDiagnosticsWhenEnabled(agent.extension));
|
const includeInteractionId = isProposedApiEnabled(agent.extension, 'chatParticipantPrivate');
|
||||||
|
const extRequest = typeConvert.ChatAgentRequest.to(includeInteractionId ? request : { ...request, requestId: '' }, location, model, this.getDiagnosticsWhenEnabled(agent.extension));
|
||||||
inFlightRequest = { requestId: requestDto.requestId, extRequest };
|
inFlightRequest = { requestId: requestDto.requestId, extRequest };
|
||||||
this._inFlightRequests.add(inFlightRequest);
|
this._inFlightRequests.add(inFlightRequest);
|
||||||
|
|
||||||
|
|||||||
@@ -2768,7 +2768,7 @@ export namespace ChatAgentRequest {
|
|||||||
export function to(request: IChatAgentRequest, location2: vscode.ChatRequestEditorData | vscode.ChatRequestNotebookData | undefined, model: vscode.LanguageModelChat, diagnostics: readonly [vscode.Uri, readonly vscode.Diagnostic[]][]): vscode.ChatRequest {
|
export function to(request: IChatAgentRequest, location2: vscode.ChatRequestEditorData | vscode.ChatRequestNotebookData | undefined, model: vscode.LanguageModelChat, diagnostics: readonly [vscode.Uri, readonly vscode.Diagnostic[]][]): vscode.ChatRequest {
|
||||||
const toolReferences = request.variables.variables.filter(v => v.isTool);
|
const toolReferences = request.variables.variables.filter(v => v.isTool);
|
||||||
const variableReferences = request.variables.variables.filter(v => !v.isTool);
|
const variableReferences = request.variables.variables.filter(v => !v.isTool);
|
||||||
return {
|
const requestWithoutId = {
|
||||||
prompt: request.message,
|
prompt: request.message,
|
||||||
command: request.command,
|
command: request.command,
|
||||||
attempt: request.attempt ?? 0,
|
attempt: request.attempt ?? 0,
|
||||||
@@ -2783,6 +2783,14 @@ export namespace ChatAgentRequest {
|
|||||||
toolInvocationToken: Object.freeze({ sessionId: request.sessionId }) as never,
|
toolInvocationToken: Object.freeze({ sessionId: request.sessionId }) as never,
|
||||||
model
|
model
|
||||||
};
|
};
|
||||||
|
if (request.requestId) {
|
||||||
|
return {
|
||||||
|
...requestWithoutId,
|
||||||
|
id: request.requestId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// This cast is done to allow sending the stabl version of ChatRequest which does not have an id property
|
||||||
|
return requestWithoutId as unknown as vscode.ChatRequest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ declare module 'vscode' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ChatRequest {
|
export interface ChatRequest {
|
||||||
|
/**
|
||||||
|
* The id of the chat request. Used to identity an interaction with any of the chat surfaces.
|
||||||
|
*/
|
||||||
|
readonly id: string;
|
||||||
/**
|
/**
|
||||||
* The attempt number of the request. The first request has attempt number 0.
|
* The attempt number of the request. The first request has attempt number 0.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user