"use client"; import { useState } from "react"; import { Client } from "@gradio/client"; export default function LearnixChatbot() { const [question, setQuestion] = useState(""); const [answer, setAnswer] = useState(""); const [loading, setLoading] = useState(false); const askBot = async () => { if (!question) return; setLoading(true); try { const client = await Client.connect("shashidharak99/learnix-chatbot"); const result = await client.predict("/chat", { question: question, }); setAnswer(result.data); } catch (err) { console.error(err); setAnswer("Error contacting chatbot."); } setLoading(false); }; return (

Learnix Chatbot

setQuestion(e.target.value)} style={{ width: "100%", padding: "10px", marginBottom: "10px", border: "1px solid #ccc", }} /> {answer && (
Answer:

{answer}

)}
); }