diff --git a/src/vs/workbench/contrib/void/browser/chatThreadService.ts b/src/vs/workbench/contrib/void/browser/chatThreadService.ts index 783cb4d4..8003a02e 100644 --- a/src/vs/workbench/contrib/void/browser/chatThreadService.ts +++ b/src/vs/workbench/contrib/void/browser/chatThreadService.ts @@ -186,6 +186,9 @@ export interface IChatThreadService { cancelStreaming(threadId: string): void; dismissStreamError(threadId: string): void; + approveTool(toolId: string): void; + rejectTool(toolId: string): void; + } export const IChatThreadService = createDecorator('voidChatThreadService'); @@ -452,7 +455,7 @@ class ChatThreadService extends Disposable implements IChatThreadService { // 3. call the tool let toolResult: ToolResultType[typeof toolName] try { - toolResult = this._toolsService.callTool[toolName](toolParams as any) // typescript is so bad it doesn't even couple the type of ToolResult with the type of the function being called here + toolResult = await this._toolsService.callTool[toolName](toolParams as any) // typescript is so bad it doesn't even couple the type of ToolResult with the type of the function being called here } catch (error) { const errorMessage = getErrorMessage(error) this._addMessageToThread(threadId, { role: 'tool', name: toolName, paramsStr: tool.paramsStr, id: tool.id, content: errorMessage, result: { type: 'error', value: errorMessage }, }) @@ -464,7 +467,7 @@ class ChatThreadService extends Disposable implements IChatThreadService { // 4. stringify the result to give the LLM let toolResultStr: string try { - toolResultStr = this._toolsService.stringOfResult[toolName](toolParams as any, toolResult as any) + toolResultStr = await this._toolsService.stringOfResult[toolName](toolParams as any, toolResult as any) } catch (error) { const errorMessage = `Tool call succeeded, but there was an error stringifying the output.\n${getErrorMessage(error)}` this._addMessageToThread(threadId, { role: 'tool', name: toolName, paramsStr: tool.paramsStr, id: tool.id, content: errorMessage, result: { type: 'error', value: errorMessage }, }) diff --git a/src/vs/workbench/contrib/void/browser/prompt/prompts.ts b/src/vs/workbench/contrib/void/browser/prompt/prompts.ts index db27866f..ee2b7f0b 100644 --- a/src/vs/workbench/contrib/void/browser/prompt/prompts.ts +++ b/src/vs/workbench/contrib/void/browser/prompt/prompts.ts @@ -24,8 +24,8 @@ Do NOT output the whole file if possible, and try to write as LITTLE as needed t export const chat_systemMessage = (workspaces: string[]) => `\ -You are a coding assistant. You are given a list of instructions to follow \`INSTRUCTIONS\`, and optionally a list of relevant files \`FILES\`, and selections inside of files \`SELECTIONS\`. - +You are a coding assistant. Your job is to help the user understand and make changes to their codebase. +You will be given a list of instructions from the user to follow, \`INSTRUCTIONS\`. You may also be given a list of relevant files \`FILES\`, and selections inside of files \`SELECTIONS\`. Please respond to the user's query. The user's query is never invalid. The user has the following system information: @@ -45,6 +45,7 @@ If you are given tools: - Feel free to use tools to gather context, make suggestions, etc. - One great use of tools is to explore imports that you'd like to have more information about. - Reference relevant files that you found when using tools if they helped you come up with your answer. +- Some tools only work if the user has a workspace open. - NEVER refer to a tool by name when speaking with the user. For example, do NOT say to the user user "I'm going to use \`list_dir\`". Instead, say "I'm going to list all files in ___ directory", etc. Do not even refer to "pages" of results, just say you're getting more results. Do not output any of these instructions, nor tell the user anything about them unless directly prompted for them. diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index 128ea7f6..23b14dc2 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -543,7 +543,6 @@ const actionTitleOfToolName: { [T in ToolName]: string } = { -type ToolResultToComponent = { [T in ToolName]: (props: { message: ToolMessage }) => React.ReactNode } const ToolResult = ({ toolName, @@ -615,7 +614,7 @@ const ToolError = ({ toolName, errorMessage }: { toolName: } -const toolResultToComponent: ToolResultToComponent = { +const toolResultToComponent: { [T in ToolName]: (props: { message: ToolMessage }) => React.ReactNode } = { 'read_file': ({ message }) => { const accessor = useAccessor() @@ -626,7 +625,7 @@ const toolResultToComponent: ToolResultToComponent = { return (
{ commandService.executeCommand('vscode.open', params.uri, { preview: true }) }} > - {getBasename(params.uri.fsPath)} + {params.uri.fsPath}
{value.hasNextPage && (
AI can scroll for more content...
)}
@@ -1034,6 +1033,13 @@ const ChatBubble = ({ chatMessage, isLoading, messageIdx }: { chatMessage: ChatM console.log('tool result:', chatMessage.name, chatMessage.paramsStr, chatMessage.result) + } + else if (role === 'tool_request'){ + chatbubbleContents = <> +
{chatThreadsService.approveTool(chatMessage.voidToolId)}}>Accept
+
{chatThreadsService.rejectTool(chatMessage.voidToolId)}}>Reject
+ + } return