thinking indicator
This commit is contained in:
parent
4ca852642c
commit
98296ff125
2 changed files with 49 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ import ResponseActions from "./ResponseActions";
|
|||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { selectUIConfig } from "../../redux/slices/configSlice";
|
||||
import { deleteMessage } from "../../redux/slices/sessionSlice";
|
||||
import ThinkingIndicator from "./ThinkingIndicator";
|
||||
|
||||
interface StepContainerProps {
|
||||
item: ChatHistoryItem;
|
||||
|
|
@ -95,8 +96,11 @@ export default function StepContainer(props: StepContainerProps) {
|
|||
itemIndex={props.index}
|
||||
/>
|
||||
)}
|
||||
{props.isLast && (
|
||||
<ThinkingIndicator messageContent={props.item.message.content} />
|
||||
)}
|
||||
</ContentDiv>
|
||||
{/* We want to occupy space in the DOM regardless of whether the actions are visible to avoid jank on */}
|
||||
{/* We want to occupy space in the DOM regardless of whether the actions are visible to avoid jank on stream complete */}
|
||||
<div className={`mt-2 h-7 transition-opacity duration-300 ease-in-out`}>
|
||||
{!shouldHideActions && (
|
||||
<ResponseActions
|
||||
|
|
|
|||
44
gui/src/components/StepContainer/ThinkingIndicator.tsx
Normal file
44
gui/src/components/StepContainer/ThinkingIndicator.tsx
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { selectDefaultModel } from "../../redux/slices/configSlice";
|
||||
import { MessageContent } from "core";
|
||||
|
||||
interface ThinkingIndicatorProps {
|
||||
messageContent: MessageContent;
|
||||
}
|
||||
/*
|
||||
Thinking animation
|
||||
Only for reasoning (long load time) models for now
|
||||
*/
|
||||
const ThinkingIndicator = ({ messageContent }: ThinkingIndicatorProps) => {
|
||||
// Animation for thinking ellipses
|
||||
const [animation, setAnimation] = useState(2);
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setAnimation((prevState) => (prevState === 2 ? 0 : prevState + 1));
|
||||
}, 600);
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const selectedModel = useAppSelector(selectDefaultModel);
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
|
||||
const hasContent = Array.isArray(messageContent)
|
||||
? !!messageContent.length
|
||||
: !!messageContent;
|
||||
const isO1 = selectedModel?.model.startsWith("o1");
|
||||
const isThinking = isStreaming && !hasContent;
|
||||
if (!isThinking || !isO1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="px-2 py-2">
|
||||
<span className="text-stone-500">{`Thinking.${".".repeat(animation)}`}</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ThinkingIndicator;
|
||||
Loading…
Add table
Reference in a new issue