'use client'; import { useState } from 'react'; import axios from 'axios'; export default function ChatPage() { const [question, setQuestion] = useState(''); const [history, setHistory] = useState([['User', 'Hello!']]); const askQuestion = async () => { const response = await axios.post('http://localhost:8000/chat/', { model: 'gpt-3.5-turbo', question, history }); setHistory(response.data.history); setQuestion(''); }; return (
{history.map(([speaker, text], idx) => (

{speaker}: {text}

))}
setQuestion(e.target.value)} className="px-3 py-2 border border-gray-300 shadow-sm rounded-md focus:outline-none text-black focus:ring-2 focus:ring-indigo-600" />
); }