"use client"; import { useChat } from "ai/react"; import { ChatInput, ChatMessages } from "@/app/components/ui/chat"; import { AutofillQuestion } from "./ui/autofill-prompt"; import { QueryMenu, QuerySelection, QueryDocumentUpload, QueryCollectionManage } from "./ui/query"; import { useSession } from "next-auth/react"; import { useState } from "react"; import { ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; export default function QuerySection() { const { data: session } = useSession(); const supabaseAccessToken = session?.supabaseAccessToken; const [collSelectedId, setCollSelectedId] = useState(''); const [collSelectedName, setCollSelectedName] = useState(''); const [showChat, setShowChat] = useState(true); const [showUpload, setShowUpload] = useState(false); const [showManage, setShowManage] = useState(false); const { messages, input, isLoading, handleSubmit, handleInputChange, reload, stop, } = useChat({ api: process.env.NEXT_PUBLIC_CHAT_API, headers: { // Add the access token to the request headers 'Authorization': `Bearer ${supabaseAccessToken}`, }, body: { // Add the selected document to the request body collection_id: collSelectedId, }, }); return (
{/* Toast Container */} {/* Menu Section */} {/* Document Selection/Chat Section */} {showChat ? (collSelectedId ? <> {/* Chat Section */} : ( )) : null } {/* Document Upload Section */} {showUpload ? : null} {/* Document Manage Section */} {showManage ? : null}
); }