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

Inline and document more chatAgents2 API #195640

Merged
merged 2 commits into from
Oct 16, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHostChatAgents2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class ExtHostChatAgents2 implements ExtHostChatAgentsShape2 {
slashCommand
},
{ history: context.history.map(typeConvert.ChatMessage.to) },
new Progress<vscode.InteractiveProgress>(p => {
new Progress<vscode.ChatAgentProgress>(p => {
throwIfDone();
const convertedProgress = typeConvert.ChatResponseProgress.from(p);
this._proxy.$handleProgressChunk(requestId, convertedProgress);
Expand Down Expand Up @@ -332,7 +332,7 @@ class ExtHostChatAgent {
} satisfies vscode.ChatAgent2;
}

invoke(request: vscode.ChatAgentRequest, context: vscode.ChatAgentContext, progress: Progress<vscode.InteractiveProgress>, token: CancellationToken): vscode.ProviderResult<vscode.ChatAgentResult2> {
invoke(request: vscode.ChatAgentRequest, context: vscode.ChatAgentContext, progress: Progress<vscode.ChatAgentProgress>, token: CancellationToken): vscode.ProviderResult<vscode.ChatAgentResult2> {
return this._callback(request, context, progress, token);
}
}
7 changes: 5 additions & 2 deletions src/vs/workbench/api/common/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2302,13 +2302,16 @@ export namespace InteractiveEditorResponseFeedbackKind {
}

export namespace ChatResponseProgress {
export function from(progress: vscode.InteractiveProgress): extHostProtocol.IChatResponseProgressDto {
export function from(progress: vscode.InteractiveProgress | vscode.ChatAgentProgress): extHostProtocol.IChatResponseProgressDto {
if ('placeholder' in progress && 'resolvedContent' in progress) {
return { placeholder: progress.placeholder };
} else if ('responseId' in progress) {
return { requestId: progress.responseId };
} else if ('content' in progress) {
return { content: typeof progress.content === 'string' ? progress.content : MarkdownString.from(progress.content) };
return {
content: 'markdownContent' in progress ? progress.markdownContent :
(typeof progress.content === 'string' ? progress.content : MarkdownString.from(progress.content))
};
} else if ('documents' in progress) {
return {
documents: progress.documents.map(d => ({
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4083,8 +4083,8 @@ export class InteractiveWindowInput {
//#region Interactive session

export enum InteractiveSessionVoteDirection {
Up = 1,
Down = 2
Down = 0,
Up = 1
}

export enum InteractiveSessionCopyKind {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/chat/common/chatService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ export type IChatFollowup = IChatReplyFollowup | IChatResponseCommandFollowup;

// Name has to match the one in vscode.d.ts for some reason
export enum InteractiveSessionVoteDirection {
Up = 1,
Down = 2
Down = 0,
Up = 1
}

export interface IChatVoteAction {
Expand Down
106 changes: 104 additions & 2 deletions src/vscode-dts/vscode.proposed.chatAgents2.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,110 @@ declare module 'vscode' {
variables: Record<string, ChatVariableValue[]>;
}

// TODO@API InteractiveProgress is a lot to inline...
export type ChatAgentHandler = (request: ChatAgentRequest, context: ChatAgentContext, progress: Progress<InteractiveProgress>, token: CancellationToken) => ProviderResult<ChatAgentResult2>;
// TODO@API should these each be prefixed ChatAgentProgress*?
export type ChatAgentProgress =
| ChatAgentContent
| ChatAgentTask
| ChatAgentFileTree
| ChatAgentUsedContext
| ChatAgentContentReference
| ChatAgentInlineContentReference;

/**
* Indicates a piece of content that was used by the chat agent while processing the request. Will be displayed to the user.
*/
export interface ChatAgentContentReference {
/**
* The resource that was referenced.
*/
reference: Uri | Location;
}

/**
* A reference to a piece of content that will be rendered inline with the markdown content.
*/
export interface ChatAgentInlineContentReference {
/**
* The resource being referenced.
*/
inlineReference: Uri | Location;

/**
* An alternate title for the resource.
*/
title?: string;
}

/**
* A piece of the chat response's content. Will be merged with other progress pieces as needed, and rendered as markdown.
*/
export interface ChatAgentContent {
/**
* The content as a string of markdown source.
*/
content: string;
}

/**
* Represents a piece of the chat response's content that is resolved asynchronously. It is rendered immediately with a placeholder,
* which is replaced once the full content is available.
*/
export interface ChatAgentTask {
/**
* The markdown string to be rendered immediately.
*/
placeholder: string;

/**
* A Thenable resolving to the real content. The placeholder will be replaced with this content once it's available.
*/
resolvedContent: Thenable<ChatAgentContent | ChatAgentFileTree>;
}

/**
* Represents a tree, such as a file and directory structure, rendered in the chat response.
*/
export interface ChatAgentFileTree {
/**
* The root node of the tree.
*/
treeData: ChatAgentFileTreeData;
}

/**
* Represents a node in a chat response tree.
*/
export interface ChatAgentFileTreeData {
/**
* A human-readable string describing this node.
*/
label: string;

/**
* A Uri for this node, opened when it's clicked.
*/
uri: Uri;

/**
* The children of this node.
*/
children?: ChatAgentFileTreeData[];
}

export interface ChatAgentDocumentContext {
uri: Uri;
version: number;
ranges: Range[];
}

/**
* Document references that should be used by the MappedEditsProvider.
*/
export interface ChatAgentUsedContext {
documents: ChatAgentDocumentContext[];
}

export type ChatAgentHandler = (request: ChatAgentRequest, context: ChatAgentContext, progress: Progress<ChatAgentProgress>, token: CancellationToken) => ProviderResult<ChatAgentResult2>;

export namespace chat {

Expand Down
5 changes: 5 additions & 0 deletions src/vscode-dts/vscode.proposed.chatAgents2Additions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ declare module 'vscode' {
readonly action: InteractiveSessionCopyAction | InteractiveSessionInsertAction | InteractiveSessionTerminalAction | InteractiveSessionCommandAction;
}

export interface ChatAgentContent {
// TODO@API This is an awkward way to describe this but this is temporary until inline references are fully supported and adopted
markdownContent: MarkdownString;
}

export interface ChatAgent2 {

// TODO@API We need this- can't handle telemetry on the vscode side yet
Expand Down
4 changes: 2 additions & 2 deletions src/vscode-dts/vscode.proposed.interactiveUserActions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
declare module 'vscode' {

export enum InteractiveSessionVoteDirection {
Up = 1,
Down = 2
Down = 0,
Up = 1
}

export interface InteractiveSessionVoteAction {
Expand Down