SouresKom / README.md
alkawthar alhaqq
Update README.md (#1)
a205f58 verified

import React, { useState } from "react";

// 💬 this is the free AI function async function freeAI(prompt) { try { const res = await fetch( "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.3", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ inputs: prompt }), } ); const data = await res.json(); return data[0]?.generated_text || "no answer"; } catch (err) { return "AI is offline right now."; } }

// 🧠 simple demo page export default function FreeAIDemo() { const [question, setQuestion] = useState(""); const [answer, setAnswer] = useState("");

async function handleAsk() { const reply = await freeAI(question); setAnswer(reply); }

return ( <div style={{ padding: 20 }}>

🧠 Free AI (no API key)

<textarea style={{ width: "100%", height: 80 }} placeholder="Type your question here..." value={question} onChange={(e) => setQuestion(e.target.value)} />
<button onClick={handleAsk} style={{ marginTop: 10 }}> Ask AI

Answer:

{answer}

); }