import { useState } from 'react'; function App() { const [messages, setMessages] = useState([]); const [input, setInput] = useState(''); const [isLoading, setIsLoading] = useState(false); // Replace with your model path (e.g., "your-user/model") const HF_MODEL_PATH = "theguywhosucks/Patchwork-26-beforetrain"; const handleSend = async () => { if (!input.trim()) return; setIsLoading(true); setMessages([...messages, { text: input, sender: 'user' }]); setInput(''); try { const response = await fetch( `https://api-inference.huggingface.co/models/${HF_MODEL_PATH}`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${process.env.HF_TOKEN}`, }, body: JSON.stringify({ inputs: input }), } ); if (!response.ok) throw new Error('Failed to fetch'); const data = await response.json(); // Adjust this based on your model's output format const botResponse = data[0]?.generated_text || data[0]?.answer || "Sorry, I couldn't generate a response."; setMessages((prev) => [...prev, { text: botResponse, sender: 'bot' }]); } catch (error) { setMessages((prev) => [...prev, { text: "Error: Could not get a response.", sender: 'bot' }]); } finally { setIsLoading(false); } }; return (