tool use ui improvements

This commit is contained in:
Nate 2024-11-21 23:07:01 -08:00
parent a540421a52
commit 98db7d3fc8
6 changed files with 33 additions and 37 deletions

View file

@ -4,4 +4,5 @@ docs/docs/languages
.idea/
.vscode/
.archive/
**/*.scm
**/*.scm
**/*.diff

View file

@ -77,10 +77,7 @@ export default function StepContainer(props: StepContainerProps) {
return (
<div
// className={isStepAheadOfCurCheckpoint ? "opacity-25" : "relative"}
style={{
minHeight: props.isLast ? "50vh" : 0,
}}
// className={isStepAheadOfCurCheckpoint ? "opacity-25" : "relative"}
>
<ContentDiv>
{uiConfig?.displayRawMarkdown ? (

View file

@ -29,6 +29,7 @@ import { defaultModelSelector } from "../redux/selectors/modelSelectors";
import {
abortStream,
acceptToolCall,
addContextItemsAtIndex,
addPromptCompletionPair,
clearLastEmptyResponse,
initNewActiveMessage,
@ -398,6 +399,18 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) {
};
dispatch(streamUpdate(newMessage));
dispatch(
addContextItemsAtIndex({
index: history.length,
contextItems: toolOutput.map((contextItem) => ({
...contextItem,
id: {
providerTitle: "toolCall",
itemId: toolCallId,
},
})),
}),
);
dispatch(acceptToolCall());
activeRef.current = true;
dispatch(setActive());

View file

@ -6,16 +6,8 @@ import {
} from "@heroicons/react/24/outline";
import { JSONContent } from "@tiptap/react";
import { InputModifiers } from "core";
import { renderChatMessage } from "core/util/messageContent";
import { usePostHog } from "posthog-js/react";
import {
Fragment,
useCallback,
useContext,
useEffect,
useRef,
useState,
} from "react";
import { useCallback, useContext, useEffect, useRef, useState } from "react";
import { ErrorBoundary } from "react-error-boundary";
import { useDispatch, useSelector } from "react-redux";
import styled from "styled-components";
@ -28,6 +20,7 @@ import {
import { ChatScrollAnchor } from "../../components/ChatScrollAnchor";
import { useFindWidget } from "../../components/find/FindWidget";
import TimelineItem from "../../components/gui/TimelineItem";
import ChatIndexingPeeks from "../../components/indexing/ChatIndexingPeeks";
import ContinueInputBox from "../../components/mainInput/ContinueInputBox";
import { NewSessionButton } from "../../components/mainInput/NewSessionButton";
import { TutorialCard } from "../../components/mainInput/TutorialCard";
@ -60,11 +53,10 @@ import {
} from "../../util";
import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial";
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
import ConfigErrorIndicator from "./ConfigError";
import { ToolCallDiv } from "./ToolCallDiv";
import { ToolCallButtons } from "./ToolCallDiv/ToolCallButtonsDiv";
import ToolOutput from "./ToolCallDiv/ToolOutput";
import ConfigErrorIndicator from "./ConfigError";
import ChatIndexingPeeks from "../../components/indexing/ChatIndexingPeeks";
const StopButton = styled.div`
background-color: ${vscBackground};
@ -332,7 +324,12 @@ export function Chat() {
>
{highlights}
{state.history.map((item, index: number) => (
<Fragment key={item.message.id}>
<div
key={item.message.id}
style={{
minHeight: index === state.history.length - 1 ? "50vh" : 0,
}}
>
<ErrorBoundary
FallbackComponent={fallbackRender}
onReset={() => {
@ -351,7 +348,7 @@ export function Chat() {
/>
) : item.message.role === "tool" ? (
<ToolOutput
output={renderChatMessage(item.message)}
contextItems={item.contextItems}
toolCallId={item.message.toolCallId}
/>
) : item.message.role === "assistant" &&
@ -401,7 +398,7 @@ export function Chat() {
</div>
)}
</ErrorBoundary>
</Fragment>
</div>
))}
<ChatScrollAnchor
scrollAreaRef={stepsDivRef}

View file

@ -14,7 +14,7 @@ export function FunctionSpecificHeader(props: FunctionSpecificHeaderProps) {
switch (props.toolCall.function.name) {
case "create_new_file":
message = "Continue wants to create a new file";
message = "Continue wants to write to a file";
break;
case "run_terminal_command":
message = "Continue wants to run a terminal command.";

View file

@ -1,33 +1,21 @@
import { ContextItemWithId } from "core";
import ContextItemsPeek from "../../../components/mainInput/ContextItemsPeek";
interface ToolOutputProps {
output: string;
contextItems: ContextItemWithId[];
toolCallId: string;
}
function ToolOutput(props: ToolOutputProps) {
if (
props.output === undefined ||
props.output === null ||
props.output.trim() === ""
) {
if (props.contextItems.length === 0) {
return null;
}
return (
<div>
<ContextItemsPeek
isCurrentContextPeek={false}
contextItems={[
{
content: props.output,
name: "Tool Call",
id: {
itemId: props.toolCallId,
providerTitle: "tool-call",
},
description: "Tool Call",
},
]}
contextItems={props.contextItems}
/>
</div>
);