import useLLM from "@react-llm/headless"; import Image from "next/image"; import { useCallback, useEffect, useState } from "react"; import MessageList from './MessageList'; import {FileLoader} from './FileLoader'; import Loader from "./Loader"; function ChatWindow({ stopStrings, maxTokens, }) { const { loadingStatus, send, isGenerating, setOnMessage } = useLLM(); const [fileId, setFileId] = useState(); const [userInput, setUserInput] = useState(""); const handleChange = (event) => { setUserInput(event.target.value); }; const isReady = loadingStatus.progress === 1; const handleSubmit = useCallback(() => { if (isGenerating || !isReady) { return; } if (fileId) { console.log('we have a fileId, so this should be contextual chat') } send(userInput, maxTokens, stopStrings); setUserInput(""); }, [ userInput, send, isGenerating, isReady, maxTokens, stopStrings ]); useEffect(() => { const handleKeyPress = (event) => { if (event.key === "Enter") { event.preventDefault(); handleSubmit(); } }; window.addEventListener("keydown", handleKeyPress); return () => { window.removeEventListener("keydown", handleKeyPress); }; }, [handleSubmit]); const loadFile = async () => { console.log('test'); } useEffect(() => { console.log('have a fileId, look it up and summarize after uploading for demo'); loadFile(); }, [fileId]) return (