diff --git a/gui/src/components/StepContainer/Reasoning.tsx b/gui/src/components/StepContainer/Reasoning.tsx deleted file mode 100644 index b2c7ec19e..000000000 --- a/gui/src/components/StepContainer/Reasoning.tsx +++ /dev/null @@ -1,138 +0,0 @@ -import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/solid"; -import { ChatHistoryItem } from "core"; -import { stripImages } from "core/util/messageContent"; -import { useEffect, useState } from "react"; -import styled from "styled-components"; -import { - defaultBorderRadius, - lightGray, - vscBackground, - vscQuickInputBackground, -} from ".."; -import { getFontSize } from "../../util"; -import StyledMarkdownPreview from "../StyledMarkdownPreview"; - -interface ReasoningProps { - item: ChatHistoryItem; - index: number; - isLast: boolean; -} - -const SpoilerButton = styled.div` - margin: 8px 6px 16px 6px; - background-color: ${vscBackground}; - width: fit-content; - font-size: ${getFontSize() - 2}px; - border: 0.5px solid ${lightGray}; - border-radius: ${defaultBorderRadius}; - padding: 4px 8px; - color: ${lightGray}; - cursor: pointer; - box-shadow: - 0 4px 6px rgba(0, 0, 0, 0.1), - 0 1px 3px rgba(0, 0, 0, 0.08); - transition: box-shadow 0.3s ease; - - &:hover { - box-shadow: - 0 6px 8px rgba(0, 0, 0, 0.15), - 0 3px 6px rgba(0, 0, 0, 0.1); - } -`; - -const ButtonContent = styled.div` - display: flex; - align-items: center; - gap: 6px; -`; - -const ContentDiv = styled.div<{ fontSize?: number }>` - margin: 4px; - padding: 4px; - padding-bottom: 8px; - font-size: ${getFontSize()}px; - overflow: hidden; - border-left: 4px solid ${lightGray}; - border-radius: ${defaultBorderRadius}; - background-color: ${vscQuickInputBackground}; -`; - -const ThinkingText = styled.span` - position: relative; - padding-right: 12px; - - &:after { - content: "..."; - position: absolute; - animation: ellipsis 1s steps(4, end) infinite; - width: 0px; - display: inline-block; - overflow: hidden; - } - - @keyframes ellipsis { - 0%, - 100% { - width: 0px; - } - 33% { - width: 8px; - } - 66% { - width: 16px; - } - 90% { - width: 24px; - } - } -`; - -export default function Reasoning(props: ReasoningProps) { - const [open, setOpen] = useState(false); - const [reasoningTime, setReasoningTime] = useState(""); - const isThinking = !props.item.reasoning?.endAt; - - useEffect(() => { - if (!props.item.reasoning) return; - if (!props.item.reasoning?.endAt) return; - - const startAt = props.item.reasoning?.startAt || Date.now(); - const endAt = props.item.reasoning?.endAt || Date.now(); - const diff = endAt - startAt; - const diffString = `${(diff / 1000).toFixed(1)}s`; - setReasoningTime(diffString); - }, [props.item.reasoning?.startAt, props.item.reasoning?.endAt]); - - if (!props.item.reasoning?.text) { - return null; - } - - return ( - <> - setOpen(!open)}> - - {isThinking ? ( - Thinking - ) : ( - `Thought for ${reasoningTime}` - )} - {open ? ( - - ) : ( - - )} - - - {open && ( - - - - )} - > - ); -} diff --git a/gui/src/components/StepContainer/StepContainer.tsx b/gui/src/components/StepContainer/StepContainer.tsx index 49ae28128..540f7cda3 100644 --- a/gui/src/components/StepContainer/StepContainer.tsx +++ b/gui/src/components/StepContainer/StepContainer.tsx @@ -5,9 +5,9 @@ import { useDispatch } from "react-redux"; import { useAppSelector } from "../../redux/hooks"; import { selectUIConfig } from "../../redux/slices/configSlice"; import { deleteMessage } from "../../redux/slices/sessionSlice"; +import ThinkingBlockPeek from "../mainInput/belowMainInput/ThinkingBlockPeek"; import StyledMarkdownPreview from "../StyledMarkdownPreview"; import ConversationSummary from "./ConversationSummary"; -import Reasoning from "./Reasoning"; import ResponseActions from "./ResponseActions"; import ThinkingIndicator from "./ThinkingIndicator"; @@ -85,7 +85,14 @@ export default function StepContainer(props: StepContainerProps) { ) : ( <> - + {props.item.reasoning?.text && ( + 0 ? props.item : null} + inProgress={!props.item.reasoning?.endAt} + /> + )} div > *:first-child { @@ -39,7 +30,6 @@ function ThinkingBlockPeek({ index, prevItem, inProgress, - signature, tokens, }: ThinkingBlockPeekProps) { const [open, setOpen] = useState(false); @@ -66,58 +56,53 @@ function ThinkingBlockPeek({ return duplicateRedactedThinkingBlock ? null : ( - - - setOpen(!open)}> - - {inProgress ? ( - - {redactedThinking ? "Redacted Thinking" : "Thinking"} - - - ) : redactedThinking ? ( - "Redacted Thinking" - ) : ( - "Thought" + - (elapsedTime ? ` for ${elapsedTime}` : "") + - (tokens ? ` (${tokens} tokens)` : "") - )} - {open ? ( - - ) : ( - - )} - - + + + setOpen(!open)} + > + {inProgress ? ( + + {redactedThinking ? "Redacted Thinking" : "Thinking"} + + + ) : redactedThinking ? ( + "Redacted Thinking" + ) : ( + "Thought" + + (elapsedTime ? ` for ${elapsedTime}` : "") + + (tokens ? ` (${tokens} tokens)` : "") + )} + {open ? ( + + ) : ( + + )} + {redactedThinking ? ( - + Thinking content redacted due to safety reasons. ) : ( - <> - - - - > + + + )}