import { useState } from "react"; import Markdown from "./Markdown.jsx"; const THINK_START = "‹‹THINK››"; const THINK_END = "‹‹/THINK››"; function splitThinking(text) { const startIdx = text.indexOf(THINK_START); const endIdx = text.indexOf(THINK_END); if (startIdx !== -1 && endIdx !== -1) { const thinking = text.slice(startIdx + THINK_START.length, endIdx).trim(); const response = text.slice(endIdx + THINK_END.length).trim(); return { thinking, response }; } // Still streaming inside think block if (startIdx !== -1 && endIdx === -1) { const thinking = text.slice(startIdx + THINK_START.length).trim(); return { thinking, response: null }; } return { thinking: null, response: text }; } function ThinkingBlock({ thinking }) { const [open, setOpen] = useState(false); if (!thinking) return null; return (
{open && (
{thinking}
)}
); } function AssistantContent({ text }) { const { thinking, response } = splitThinking(text); return ( <> {response && {response}} {response === null && thinking && ( thinking... )} ); } export default function MessageList({ messages, streamingText, isStreaming, processingStep }) { return (
{messages.map((msg, i) => ( ))} {isStreaming && processingStep && !streamingText && (
G
{processingStep}...
)} {isStreaming && streamingText && (
G
)}
); } function Message({ msg }) { const isUser = msg.role === "user"; return (
{isUser ? "Y" : "G"}
{msg.videoUrl ? (
); }