'use client'; import { useChat, type Message } from 'ai/react'; import '@/app/globals.css'; import { cn } from '@/lib/utils'; import { ChatList } from '@/components/chat-list'; import { ChatPanel } from '@/components/chat-panel'; import { EmptyScreen } from '@/components/empty-screen'; import { ChatScrollAnchor } from '@/components/chat-scroll-anchor'; import { useState } from 'react'; import { Button } from './ui/button'; import { Input } from './ui/input'; import { toast } from 'react-hot-toast'; import { usePathname, useRouter } from 'next/navigation'; import { useAtom } from 'jotai'; import { targetImageAtom } from '@/state'; import Image from 'next/image'; import { ThemeToggle } from './theme-toggle'; export interface ChatProps extends React.ComponentProps<'div'> { initialMessages?: Message[]; id?: string; } export function Chat({ id, initialMessages, className }: ChatProps) { const [targetImage, setTargetImage] = useAtom(targetImageAtom); const { messages, append, reload, stop, isLoading, input, setInput } = useChat({ initialMessages, id, body: { id, image: targetImage, }, onResponse(response) { if (response.status === 401) { toast.error(response.statusText); } }, }); return ( <>
target image
); }