// 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 '@aigxion/isdk' import remarkGfm from 'remark-gfm' import remarkMath from 'remark-math' import { cn } from '@/lib/utils' import { CodeBlock } from './ui/codeblock' import { MemoizedReactMarkdown } from './markdown' import { IconOpenAI, IconUser } from './ui/icons' import { ChatMessageActions } from './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}
) }