mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-19 17:58:39 +00:00
remove dead summarization code (#278255)
This commit is contained in:
@@ -14,26 +14,18 @@ import { IChatSessionsExtensionPoint, IChatSessionsService } from '../../common/
|
||||
import { Codicon } from '../../../../../base/common/codicons.js';
|
||||
import { AgentSessionProviders, getAgentSessionProviderIcon, getAgentSessionProviderName } from '../agentSessions/agentSessions.js';
|
||||
import { localize, localize2 } from '../../../../../nls.js';
|
||||
import { CancellationToken } from '../../../../../base/common/cancellation.js';
|
||||
import { basename, relativePath } from '../../../../../base/common/resources.js';
|
||||
import { basename } from '../../../../../base/common/resources.js';
|
||||
import { URI } from '../../../../../base/common/uri.js';
|
||||
import { generateUuid } from '../../../../../base/common/uuid.js';
|
||||
import { ServicesAccessor } from '../../../../../editor/browser/editorExtensions.js';
|
||||
import { isLocation } from '../../../../../editor/common/languages.js';
|
||||
import { isITextModel } from '../../../../../editor/common/model.js';
|
||||
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
|
||||
import { IWorkspaceContextService } from '../../../../../platform/workspace/common/workspace.js';
|
||||
import { IEditorService } from '../../../../services/editor/common/editorService.js';
|
||||
import { IChatAgentService, IChatAgent, IChatAgentHistoryEntry } from '../../common/chatAgents.js';
|
||||
import { IChatAgentService } from '../../common/chatAgents.js';
|
||||
import { ChatContextKeys } from '../../common/chatContextKeys.js';
|
||||
import { IChatRequestModel, toChatHistoryContent } from '../../common/chatModel.js';
|
||||
import { ChatRequestParser } from '../../common/chatRequestParser.js';
|
||||
import { IChatService } from '../../common/chatService.js';
|
||||
import { chatSessionResourceToId } from '../../common/chatUri.js';
|
||||
import { ChatRequestVariableSet, isChatRequestFileEntry } from '../../common/chatVariableEntries.js';
|
||||
import { ChatAgentLocation } from '../../common/constants.js';
|
||||
import { IChatWidgetService } from '../chat.js';
|
||||
import { MarkdownString } from '../../../../../base/common/htmlContent.js';
|
||||
import { ThemeIcon } from '../../../../../base/common/themables.js';
|
||||
import { ICommandService } from '../../../../../platform/commands/common/commands.js';
|
||||
import { CHAT_SETUP_ACTION_ID } from './chatActions.js';
|
||||
@@ -146,13 +138,6 @@ export class ChatContinueInSessionActionItem extends ActionWidgetDropdownActionV
|
||||
}
|
||||
|
||||
class CreateRemoteAgentJobAction {
|
||||
|
||||
private static readonly markdownStringTrustedOptions = {
|
||||
isTrusted: {
|
||||
enabledCommands: [] as string[],
|
||||
},
|
||||
};
|
||||
|
||||
constructor() { }
|
||||
|
||||
async run(accessor: ServicesAccessor, continuationTarget: IChatSessionsExtensionPoint) {
|
||||
@@ -165,7 +150,6 @@ class CreateRemoteAgentJobAction {
|
||||
const widgetService = accessor.get(IChatWidgetService);
|
||||
const chatAgentService = accessor.get(IChatAgentService);
|
||||
const chatService = accessor.get(IChatService);
|
||||
const workspaceContextService = accessor.get(IWorkspaceContextService);
|
||||
const editorService = accessor.get(IEditorService);
|
||||
|
||||
const widget = widgetService.lastFocusedWidget;
|
||||
@@ -233,73 +217,10 @@ class CreateRemoteAgentJobAction {
|
||||
defaultAgent
|
||||
);
|
||||
|
||||
let title: string | undefined = undefined;
|
||||
|
||||
// -- summarize userPrompt if necessary
|
||||
let summarizedUserPrompt: string | undefined = undefined;
|
||||
if (defaultAgent && userPrompt.length > 10_000) {
|
||||
chatModel.acceptResponseProgress(addedRequest, {
|
||||
kind: 'progressMessage',
|
||||
content: new MarkdownString(
|
||||
localize('summarizeUserPromptCreateRemoteJob', "Summarizing user prompt"),
|
||||
CreateRemoteAgentJobAction.markdownStringTrustedOptions,
|
||||
)
|
||||
});
|
||||
|
||||
({ title, summarizedUserPrompt } = await this.generateSummarizedUserPrompt(sessionResource, userPrompt, attachedContext, title, chatAgentService, defaultAgent, summarizedUserPrompt));
|
||||
}
|
||||
|
||||
let summary: string = '';
|
||||
|
||||
// Add selection or cursor information to the summary
|
||||
attachedContext.asArray().forEach(ctx => {
|
||||
if (isChatRequestFileEntry(ctx) && ctx.value && isLocation(ctx.value)) {
|
||||
const range = ctx.value.range;
|
||||
const isSelection = range.startLineNumber !== range.endLineNumber || range.startColumn !== range.endColumn;
|
||||
|
||||
// Get relative path for the file
|
||||
let filePath = ctx.name;
|
||||
const workspaceFolder = workspaceContextService.getWorkspaceFolder(ctx.value.uri);
|
||||
|
||||
if (workspaceFolder && ctx.value.uri) {
|
||||
const relativePathResult = relativePath(workspaceFolder.uri, ctx.value.uri);
|
||||
if (relativePathResult) {
|
||||
filePath = relativePathResult;
|
||||
}
|
||||
}
|
||||
|
||||
if (isSelection) {
|
||||
summary += `User has selected text in file ${filePath} from ${range.startLineNumber}:${range.startColumn} to ${range.endLineNumber}:${range.endColumn}\n`;
|
||||
} else {
|
||||
summary += `User is on file ${filePath} at position ${range.startLineNumber}:${range.startColumn}\n`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// -- summarize context if necessary
|
||||
if (defaultAgent && chatRequests.length > 1) {
|
||||
chatModel.acceptResponseProgress(addedRequest, {
|
||||
kind: 'progressMessage',
|
||||
content: new MarkdownString(
|
||||
localize('analyzingChatHistory', "Analyzing chat history"),
|
||||
CreateRemoteAgentJobAction.markdownStringTrustedOptions
|
||||
)
|
||||
});
|
||||
({ title, summary } = await this.generateSummarizedChatHistory(chatRequests, sessionResource, title, chatAgentService, defaultAgent, summary));
|
||||
}
|
||||
|
||||
if (title) {
|
||||
summary += `\nTITLE: ${title}\n`;
|
||||
}
|
||||
|
||||
await chatService.removeRequest(sessionResource, addedRequest.id);
|
||||
await chatService.sendRequest(sessionResource, userPrompt, {
|
||||
agentIdSilent: continuationTargetType,
|
||||
attachedContext: attachedContext.asArray(),
|
||||
chatSummary: {
|
||||
prompt: summarizedUserPrompt,
|
||||
history: summary,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Error creating remote coding agent job', e);
|
||||
@@ -308,52 +229,4 @@ class CreateRemoteAgentJobAction {
|
||||
remoteJobCreatingKey.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
private async generateSummarizedChatHistory(chatRequests: IChatRequestModel[], sessionResource: URI, title: string | undefined, chatAgentService: IChatAgentService, defaultAgent: IChatAgent, summary: string) {
|
||||
const historyEntries: IChatAgentHistoryEntry[] = chatRequests
|
||||
.map((req): IChatAgentHistoryEntry => ({
|
||||
request: {
|
||||
sessionId: chatSessionResourceToId(sessionResource),
|
||||
sessionResource,
|
||||
requestId: req.id,
|
||||
agentId: req.response?.agent?.id ?? '',
|
||||
message: req.message.text,
|
||||
command: req.response?.slashCommand?.name,
|
||||
variables: req.variableData,
|
||||
location: ChatAgentLocation.Chat,
|
||||
editedFileEvents: req.editedFileEvents,
|
||||
},
|
||||
response: toChatHistoryContent(req.response!.response.value),
|
||||
result: req.response?.result ?? {}
|
||||
}));
|
||||
|
||||
// TODO: Determine a cutoff point where we stop including earlier history
|
||||
// For example, if the user has already delegated to a coding agent once,
|
||||
// prefer the conversation afterwards.
|
||||
title ??= await chatAgentService.getChatTitle(defaultAgent.id, historyEntries, CancellationToken.None);
|
||||
summary += await chatAgentService.getChatSummary(defaultAgent.id, historyEntries, CancellationToken.None);
|
||||
return { title, summary };
|
||||
}
|
||||
|
||||
private async generateSummarizedUserPrompt(sessionResource: URI, userPrompt: string, attachedContext: ChatRequestVariableSet, title: string | undefined, chatAgentService: IChatAgentService, defaultAgent: IChatAgent, summarizedUserPrompt: string | undefined) {
|
||||
const userPromptEntry: IChatAgentHistoryEntry = {
|
||||
request: {
|
||||
sessionId: chatSessionResourceToId(sessionResource),
|
||||
sessionResource,
|
||||
requestId: generateUuid(),
|
||||
agentId: '',
|
||||
message: userPrompt,
|
||||
command: undefined,
|
||||
variables: { variables: attachedContext.asArray() },
|
||||
location: ChatAgentLocation.Chat,
|
||||
editedFileEvents: [],
|
||||
},
|
||||
response: [],
|
||||
result: {}
|
||||
};
|
||||
const historyEntries = [userPromptEntry];
|
||||
title = await chatAgentService.getChatTitle(defaultAgent.id, historyEntries, CancellationToken.None);
|
||||
summarizedUserPrompt = await chatAgentService.getChatSummary(defaultAgent.id, historyEntries, CancellationToken.None);
|
||||
return { title, summarizedUserPrompt };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user