"use client"; import { Attachment, ToolInvocation } from "ai"; import { motion } from "framer-motion"; import { ReactNode } from "react"; import { BotIcon, UserIcon } from "./icons"; 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.map((toolInvocation) => { const { toolName, toolCallId, state } = toolInvocation; if (state === "result") { const { result } = toolInvocation; return (
{toolName === "getWeather" ? ( ) : null}
); } else { return (
{toolName === "getWeather" ? : null}
); } })}
)} {attachments && (
{attachments.map((attachment) => ( ))}
)}
); };