"use client"; import { useChat } from "ai/react"; import { ChatInput, ChatMessages } from "./ui/chat"; export default function ChatSection() { const { messages, input, isLoading, handleSubmit, handleInputChange, reload, stop, } = useChat({ api: process.env.NEXT_PUBLIC_CHAT_API, headers: { "Content-Type": "application/json", // using JSON because of vercel/ai 2.2.26 }, onError: (error: unknown) => { if (!(error instanceof Error)) throw error; const message = JSON.parse(error.message); alert(message.detail); }, }); return (