auto call tool

This commit is contained in:
Nate 2024-11-22 23:07:29 -08:00
parent e6d7f5b511
commit ae784b9ed0
2 changed files with 25 additions and 2 deletions

View file

@ -1,4 +1,4 @@
import { useContext } from "react";
import { useContext, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import styled from "styled-components";
import {
@ -55,8 +55,22 @@ export function ToolCallButtons(props: ToolCallButtonsProps) {
const toolCallState = useSelector(
(store: RootState) => store.state.currentToolCallState,
);
const toolSetting = useSelector(
(store: RootState) =>
store.uiState.toolSettings[toolCallState.toolCall.function.name],
);
const ideMessenger = useContext(IdeMessengerContext);
useEffect(() => {
if (
toolCallState.currentToolCallState === "generated" &&
toolSetting === "allowedWithoutPermission"
) {
callTool();
}
}, [toolCallState.currentToolCallState, toolSetting]);
const { streamResponseAfterToolCall } = useChatHandler(
dispatch,
ideMessenger,

View file

@ -1,4 +1,5 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { BuiltInToolNames } from "core/tools/builtIn";
import {
defaultOnboardingCardState,
OnboardingCardState,
@ -31,7 +32,15 @@ export const uiStateSlice = createSlice({
shouldAddFileForEditing: false,
useTools: false,
toolSettings: {},
toolSettings: {
[BuiltInToolNames.CreateNewFile]: "allowedWithPermission",
[BuiltInToolNames.RunTerminalCommand]: "allowedWithPermission",
[BuiltInToolNames.ViewSubdirectory]: "allowedWithoutPermission",
[BuiltInToolNames.ViewRepoMap]: "allowedWithoutPermission",
[BuiltInToolNames.ExactSearch]: "allowedWithoutPermission",
[BuiltInToolNames.SearchWeb]: "allowedWithoutPermission",
[BuiltInToolNames.ViewDiff]: "allowedWithoutPermission",
},
} as UiState,
reducers: {
setOnboardingCard: (