add resubmit button to simple tool UI
This commit is contained in:
parent
55ff11fc2e
commit
155525db20
5 changed files with 45 additions and 25 deletions
|
|
@ -18,6 +18,7 @@ import {
|
|||
PlusIcon,
|
||||
SparklesIcon,
|
||||
TrashIcon,
|
||||
WrenchScrewdriverIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { DiscordIcon } from "../svg/DiscordIcon";
|
||||
import { GithubIcon } from "../svg/GithubIcon";
|
||||
|
|
@ -55,4 +56,5 @@ export const NAMED_ICONS: { [key: string]: any } = {
|
|||
"gitlab-mr": GitlabIcon,
|
||||
http: GlobeAltIcon,
|
||||
trash: TrashIcon,
|
||||
toolCall: WrenchScrewdriverIcon,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -330,7 +330,6 @@ export function Chat() {
|
|||
key={i}
|
||||
toolCallState={item.toolCallState!}
|
||||
toolCall={toolCall}
|
||||
output={history[index + 1]?.contextItems}
|
||||
historyIndex={index}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,26 +1,27 @@
|
|||
import { ChevronRightIcon } from "@heroicons/react/24/outline";
|
||||
import { ContextItemWithId, Tool, ToolCallState } from "core";
|
||||
import { ArrowPathIcon, ChevronRightIcon } from "@heroicons/react/24/outline";
|
||||
import { Tool, ToolCallState } from "core";
|
||||
import { ComponentType, useMemo, useState } from "react";
|
||||
import { ContextItemsPeekItem } from "../../../components/mainInput/belowMainInput/ContextItemsPeek";
|
||||
import { ToolbarButtonWithTooltip } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip";
|
||||
import { ArgsItems, ArgsToggleIcon } from "./ToolCallArgs";
|
||||
import { toolCallStateToContextItems } from "./toolCallStateToContextItem";
|
||||
import { ToolCallStatusMessage } from "./ToolCallStatusMessage";
|
||||
|
||||
interface SimpleToolCallUIProps {
|
||||
toolCallState: ToolCallState;
|
||||
tool: Tool | undefined;
|
||||
contextItems: ContextItemWithId[];
|
||||
icon?: ComponentType<React.SVGProps<SVGSVGElement>>;
|
||||
}
|
||||
|
||||
export function SimpleToolCallUI({
|
||||
contextItems,
|
||||
icon: Icon,
|
||||
toolCallState,
|
||||
tool,
|
||||
}: SimpleToolCallUIProps) {
|
||||
const ctxItems = useMemo(() => {
|
||||
return contextItems?.filter((ctxItem) => !ctxItem.hidden) ?? [];
|
||||
}, [contextItems]);
|
||||
const shownContextItems = useMemo(() => {
|
||||
const contextItems = toolCallStateToContextItems(toolCallState);
|
||||
return contextItems.filter((item) => !item.hidden);
|
||||
}, [toolCallState]);
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
|
|
@ -54,13 +55,23 @@ export function SimpleToolCallUI({
|
|||
</div>
|
||||
<ToolCallStatusMessage tool={tool} toolCallState={toolCallState} />
|
||||
</div>
|
||||
{args.length > 0 ? (
|
||||
<ArgsToggleIcon
|
||||
isShowing={showingArgs}
|
||||
setIsShowing={setShowingArgs}
|
||||
toolCallId={toolCallState.toolCallId}
|
||||
/>
|
||||
) : null}
|
||||
<div>
|
||||
<ToolbarButtonWithTooltip
|
||||
tooltipContent="Resubmit"
|
||||
onClick={() => {
|
||||
console.log("Resubmit clicked");
|
||||
}}
|
||||
>
|
||||
<ArrowPathIcon className="h-4 w-4" />
|
||||
</ToolbarButtonWithTooltip>
|
||||
{args.length > 0 ? (
|
||||
<ArgsToggleIcon
|
||||
isShowing={showingArgs}
|
||||
setIsShowing={setShowingArgs}
|
||||
toolCallId={toolCallState.toolCallId}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<ArgsItems args={args} isShowing={showingArgs} />
|
||||
<div
|
||||
|
|
@ -68,8 +79,8 @@ export function SimpleToolCallUI({
|
|||
open ? "max-h-[50vh] opacity-100" : "max-h-0 opacity-0"
|
||||
}`}
|
||||
>
|
||||
{ctxItems.length ? (
|
||||
ctxItems.map((contextItem, idx) => (
|
||||
{shownContextItems.length ? (
|
||||
shownContextItems.map((contextItem, idx) => (
|
||||
<ContextItemsPeekItem key={idx} contextItem={contextItem} />
|
||||
))
|
||||
) : (
|
||||
|
|
|
|||
|
|
@ -12,12 +12,7 @@ import {
|
|||
PencilIcon,
|
||||
XMarkIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import {
|
||||
ContextItemWithId,
|
||||
ToolCallDelta,
|
||||
ToolCallState,
|
||||
ToolStatus,
|
||||
} from "core";
|
||||
import { ToolCallDelta, ToolCallState, ToolStatus } from "core";
|
||||
import { BuiltInToolNames } from "core/tools/builtIn";
|
||||
import { ComponentType, useMemo } from "react";
|
||||
import { vscButtonBackground } from "../../../components";
|
||||
|
|
@ -30,7 +25,6 @@ import { ToolCallDisplay } from "./ToolCall";
|
|||
interface ToolCallDivProps {
|
||||
toolCall: ToolCallDelta;
|
||||
toolCallState: ToolCallState;
|
||||
output?: ContextItemWithId[];
|
||||
historyIndex: number;
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +80,6 @@ export function ToolCallDiv(props: ToolCallDivProps) {
|
|||
icon={
|
||||
props.toolCallState.status === "generated" ? ArrowRightIcon : icon
|
||||
}
|
||||
contextItems={props.output ?? []}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
15
gui/src/pages/gui/ToolCallDiv/toolCallStateToContextItem.ts
Normal file
15
gui/src/pages/gui/ToolCallDiv/toolCallStateToContextItem.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { ContextItemWithId, ToolCallState } from "core";
|
||||
|
||||
export function toolCallStateToContextItems(
|
||||
toolCallState: ToolCallState,
|
||||
): ContextItemWithId[] {
|
||||
return (
|
||||
toolCallState.output?.map((item) => ({
|
||||
...item,
|
||||
id: {
|
||||
providerTitle: "toolCall",
|
||||
itemId: toolCallState.toolCallId,
|
||||
},
|
||||
})) ?? []
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue