// 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 { Message } from 'ai'; 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/markdown'; import { IconOpenAI, IconUser } from '@/components/ui/icons'; import { ChatMessageActions } from '@/components/chat-message-actions'; export interface ChatMessageProps { message: Message; } export function ChatMessage({ message, ...props }: ChatMessageProps) { return (
{message.role === 'user' ? : }
{children}

; }, 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 ( ); }, }} > {message.content}
); }