// 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 { cn } from '@/lib/utils'; import { CodeBlock } from '@/components/ui/CodeBlock'; import { MemoizedReactMarkdown } from '@/components/chat/MemoizedReactMarkdown'; import { IconOpenAI, IconUser } from '@/components/ui/Icons'; import { ChatMessageActions } from '@/components/chat/ChatMessageActions'; import { MessageBase } from '../../lib/types'; import { useCleanedUpMessages } from '@/lib/hooks/useCleanedUpMessages'; import Img from '../ui/Img'; export interface ChatMessageProps { message: MessageBase; } export function ChatMessage({ message, ...props }: ChatMessageProps) { const { logs, content } = useCleanedUpMessages(message); return (
{children}
);
},
}}
>
{logs}
{children}
); } return ({children}
); }, img(props) { return ( ); }, code({ node, inline, className, children, ...props }) { if (children.length) { if (children[0] == '▍') { return ( ▍ ); } children[0] = (children[0] as string).replace('`▍`', '▍'); } const match = /language-(\w+)/.exec(className || ''); if (inline) { return (
{children}
);
}
return (