// Inspired by Chatbot-UI and modified to fit the needs of this project // @see https://github.com/mckaywrigley/chatbot-ui/blob/main/components/Chat/ChatMessage.tsx import remarkGfm from 'remark-gfm'; import remarkMath from 'remark-math'; import { useMemo } from 'react'; import { cn } from '@/lib/utils'; import { CodeBlock } from '@/components/ui/CodeBlock'; import { MemoizedReactMarkdown } from '@/components/chat/MemoizedReactMarkdown'; import { IconOpenAI, IconUser } from '@/components/ui/Icons'; import { MessageBase } from '../../lib/types'; import { Tooltip, TooltipContent, TooltipTrigger, } from '@/components/ui/Tooltip'; import Img from '../ui/Img'; import { getCleanedUpMessages } from '@/lib/messageUtils'; export interface ChatMessageProps { message: MessageBase; } export function ChatMessage({ message, ...props }: ChatMessageProps) { const { logs, content } = useMemo(() => { return getCleanedUpMessages({ content: message.content, role: message.role, }); }, [message.content, message.role]); return (
{message.role === 'user' ? : }
{logs && message.role !== 'user' && (
Thinking Process
{children}

); }, code({ children, ...props }) { return ( {children} ); }, }} > {logs}
)} child.type === 'element' && child.tagName === 'img', ) ) { return (

{children}

); } return (

{children}

); }, img(props) { if (props.src?.endsWith('.mp4')) { return (
{/* */}
); }