// 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 Image from 'next/image' import { Message } from 'ai' import remarkGfm from 'remark-gfm' import remarkMath from 'remark-math' import { MessageActionType } from '@/lib/types' import { cn } from '@/lib/utils' import { CodeBlock } from '@/components/ui/codeblock' import { IconUser } from '@/components/ui/icons' import { ChatMessageActions } from '@/components/chat-message-actions' import { MemoizedReactMarkdown } from '@/components/markdown' export interface ChatMessageProps { message: Message handleMessageAction: (messageId: string, action: MessageActionType) => void } export function ChatMessage({ message, handleMessageAction, ...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}
) } function IconTabby() { return ( tabby ) }