import { useState } from 'react' import './App.css' import { chat as chatApi, reset as resetApi } from './api' function App() { const [user, setUser] = useState('default') const [session, setSession] = useState('default') const [prompt, setPrompt] = useState('') const [messages, setMessages] = useState([]) const [loading, setLoading] = useState(false) const [error, setError] = useState(null) const sendPrompt = async () => { if (!prompt.trim()) return setLoading(true) setError(null) try { const reply = await chatApi(user, session, prompt) setMessages([...messages, { role: 'user', content: prompt }, { role: 'assistant', content: reply }]) setPrompt('') } catch (err) { setError(err.message) } finally { setLoading(false) } } const handleReset = async () => { setLoading(true) setError(null) try { await resetApi(user, session) setMessages([]) } catch (err) { setError(err.message) } finally { setLoading(false) } } return (

LLM Chat

{messages.map((m, i) => (
{m.role}: {m.content}
))}
{error &&
{error}
}