// AskOscar Herbal AI Script (Free Hugging Face API version) const chatBox = document.getElementById("chat-box"); const userInput = document.getElementById("user-input"); const sendBtn = document.getElementById("send-btn"); const aboutBtn = document.getElementById("about-btn"); const MODEL_URL = "https://api-inference.huggingface.co/models/facebook/blenderbot-400M-distill"; function addMessage(sender, text) { const message = document.createElement("div"); message.className = sender; message.innerText = text; chatBox.appendChild(message); chatBox.scrollTop = chatBox.scrollHeight; } sendBtn.addEventListener("click", () => { const userText = userInput.value.trim(); if (!userText) return; addMessage("user", userText); userInput.value = ""; addMessage("bot", "💭 Thinking..."); fetch(MODEL_URL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ inputs: `You are AskOscar Herbal AI. You only answer questions about herbs, natural healing, and plant medicine. Question: ${userText}`, }), }) .then((res) => res.json()) .then((data) => { const botResponse = data.generated_text || "I'm not sure about that herb yet. Could you rephrase your question?"; chatBox.lastChild.innerText = botResponse; }) .catch(() => { chatBox.lastChild.innerText = "⚠️ Sorry, I couldn’t connect to the herbal knowledge base."; }); }); // About button aboutBtn.addEventListener("click", () => { addMessage( "bot", "🌿 AskOscar.ai was founded by Oscar Teye — a visionary herbal researcher and natural health enthusiast dedicated to bringing nature's healing wisdom to everyone." ); });