'use client'; import { Attachment, ToolInvocation } from 'ai'; import { motion } from 'framer-motion'; import { Sparkles } from 'lucide-react'; import { ReactNode } from 'react'; import { Markdown } from './markdown'; import { PreviewAttachment } from './preview-attachment'; import { Weather } from './weather'; export const Message = ({ role, content, toolInvocations, attachments, }: { role: string; content: string | ReactNode; toolInvocations: Array | undefined; attachments?: Array; }) => { return (
{role === 'assistant' && (
)}
{content && (
{content as string}
)} {toolInvocations && toolInvocations.length > 0 ? (
{toolInvocations.map((toolInvocation) => { const { toolName, toolCallId, state } = toolInvocation; if (state === 'result') { const { result } = toolInvocation; return (
{toolName === 'getWeather' ? ( ) : null}
); } else { return (
{toolName === 'getWeather' ? : null}
); } })}
) : null} {attachments && (
{attachments.map((attachment) => ( ))}
)}
); };