diff --git a/src/components/MessageBubble.tsx b/src/components/MessageBubble.tsx index 14fc7e6..d2c0d36 100644 --- a/src/components/MessageBubble.tsx +++ b/src/components/MessageBubble.tsx @@ -1,4 +1,4 @@ -import { XMarkIcon } from "@heroicons/react/24/outline"; +import { LightBulbIcon, XMarkIcon } from "@heroicons/react/24/outline"; import Markdown from "react-markdown"; import { useContext, useState, useMemo } from "react"; import { ChatStoreMessage } from "@/types/chatstore"; @@ -16,6 +16,11 @@ import { } from "@/components/ui/chat/chat-bubble"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger, +} from "@/components/ui/collapsible"; import { useToast } from "@/hooks/use-toast"; import { ClipboardIcon, @@ -24,8 +29,10 @@ import { MessageSquarePlusIcon, AudioLinesIcon, LoaderCircleIcon, + ChevronsUpDownIcon, } from "lucide-react"; import { AppChatStoreContext, AppContext } from "@/pages/App"; +import { Card, CardContent, CardHeader, CardTitle } from "./ui/card"; interface HideMessageProps { chat: ChatStoreMessage; @@ -283,75 +290,165 @@ export default function Message(props: { messageIndex: number }) { )} - - - {chat.hide ? ( - - ) : typeof chat.content !== "string" ? ( - - ) : chat.tool_calls ? ( - - ) : chat.role === "tool" ? ( - - ) : renderMarkdown ? ( - {getMessageText(chat)} - ) : ( -
- {chat.content && - (chat.logprobs && renderColor - ? chat.logprobs.content - .filter((c) => c.token) - .map((c) => ( -
- {c.token} -
- )) - : getMessageText(chat))} -
- )} -
- - - ) : ( - - ) - } - onClick={() => { - chatStore.history[messageIndex].hide = - !chatStore.history[messageIndex].hide; - chatStore.totalTokens = 0; - for (const i of chatStore.history - .filter(({ hide }) => !hide) - .slice(chatStore.postBeginIndex) - .map(({ token }) => token)) { - chatStore.totalTokens += i; + {chat.role === "assistant" || chat.role === "received" ? ( +
+ {chat.reasoning_content ? ( + +
+
+

+ {chat.response_model_name} +

+ + + +
+
+ + {chat.reasoning_content} + +
+ ) : null} +
+ {chat.hide ? ( + + ) : typeof chat.content !== "string" ? ( + + ) : chat.tool_calls ? ( + + ) : chat.role === "tool" ? ( + + ) : renderMarkdown ? ( + {getMessageText(chat)} + ) : ( +
+ {chat.content && + (chat.logprobs && renderColor + ? chat.logprobs.content + .filter((c) => c.token) + .map((c) => ( +
+ {c.token} +
+ )) + : getMessageText(chat))} +
+ )} +
+
+ + ) : ( + + ) } - setChatStore({ ...chatStore }); - }} - /> - } - onClick={() => setShowEdit(true)} - /> - } - onClick={() => copyToClipboard(getMessageText(chat))} - /> - {chatStore.tts_api && chatStore.tts_key && } - - - + onClick={() => { + chatStore.history[messageIndex].hide = + !chatStore.history[messageIndex].hide; + chatStore.totalTokens = 0; + for (const i of chatStore.history + .filter(({ hide }) => !hide) + .slice(chatStore.postBeginIndex) + .map(({ token }) => token)) { + chatStore.totalTokens += i; + } + setChatStore({ ...chatStore }); + }} + /> + } + onClick={() => setShowEdit(true)} + /> + } + onClick={() => copyToClipboard(getMessageText(chat))} + /> + {chatStore.tts_api && chatStore.tts_key && ( + + )} + +
+
+ ) : ( + + + {chat.hide ? ( + + ) : typeof chat.content !== "string" ? ( + + ) : chat.tool_calls ? ( + + ) : chat.role === "tool" ? ( + + ) : renderMarkdown ? ( + {getMessageText(chat)} + ) : ( +
+ {chat.content && + (chat.logprobs && renderColor + ? chat.logprobs.content + .filter((c) => c.token) + .map((c) => ( +
+ {c.token} +
+ )) + : getMessageText(chat))} +
+ )} +
+ + + ) : ( + + ) + } + onClick={() => { + chatStore.history[messageIndex].hide = + !chatStore.history[messageIndex].hide; + chatStore.totalTokens = 0; + for (const i of chatStore.history + .filter(({ hide }) => !hide) + .slice(chatStore.postBeginIndex) + .map(({ token }) => token)) { + chatStore.totalTokens += i; + } + setChatStore({ ...chatStore }); + }} + /> + } + onClick={() => setShowEdit(true)} + /> + } + onClick={() => copyToClipboard(getMessageText(chat))} + /> + {chatStore.tts_api && chatStore.tts_key && ( + + )} + + +
+ )} {chatStore.develop_mode && (