'use client'; import { Message } from 'ai'; import cx from 'classnames'; import { motion } from 'framer-motion'; import { Dispatch, SetStateAction } from 'react'; import { Vote } from '@/db/schema'; import { UICanvas } from './canvas'; import { DocumentToolCall, DocumentToolResult } from './document'; import { SparklesIcon } from './icons'; import { Markdown } from './markdown'; import { MessageActions } from './message-actions'; import { PreviewAttachment } from './preview-attachment'; import { Weather } from './weather'; export const PreviewMessage = ({ chatId, message, canvas, setCanvas, vote, isLoading, }: { chatId: string; message: Message; canvas: UICanvas; setCanvas: Dispatch>; vote: Vote | undefined; isLoading: boolean; }) => { return (
{message.role === 'assistant' && (
)}
{message.content && (
{message.content as string}
)} {message.toolInvocations && message.toolInvocations.length > 0 && (
{message.toolInvocations.map((toolInvocation) => { const { toolName, toolCallId, state, args } = toolInvocation; if (state === 'result') { const { result } = toolInvocation; return (
{toolName === 'getWeather' ? ( ) : toolName === 'createDocument' ? ( ) : toolName === 'updateDocument' ? ( ) : toolName === 'requestSuggestions' ? ( ) : (
{JSON.stringify(result, null, 2)}
)}
); } else { return (
{toolName === 'getWeather' ? ( ) : toolName === 'createDocument' ? ( ) : toolName === 'updateDocument' ? ( ) : toolName === 'requestSuggestions' ? ( ) : null}
); } })}
)} {message.experimental_attachments && (
{message.experimental_attachments.map((attachment) => ( ))}
)}
); }; export const ThinkingMessage = () => { const role = 'assistant'; return (
Thinking...
); };