I lost this page
I searched high and low but couldn't find what you're looking for. Let's find a better place for you to go.
import React, { useState } from "react";
export default function AIChatBox() {
const [messages, setMessages] = useState([]);
const [inputValue, setInputValue] = useState("");
const HUGGING_FACE_API_KEY = "your_hugging_face_api_key_here";
const sendMessage = async () => {
if (!inputValue) return;
setMessages([...messages, { role: "user", content: inputValue }]);
try {
const response = await fetch("https://api-inference.huggingface.co/models/facebook/blenderbot-400M-distill", {
method: "POST",
headers: {
Authorization: `Bearer ${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}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ inputs: inputValue }),
});
const data = await response.json();
const reply = data.generated_text || "I'm having trouble thinking right now!";
setMessages((prev) => [...prev, { role: "assistant", content: reply }]);
} catch (error) {
setMessages((prev) => [...prev, { role: "assistant", content: "Something went wrong!" }]);
}
setInputValue("");
};
return (
Ask AI about $TOLMA
{messages.map((msg, index) => (
{msg.role === "user" ? "You: " : "AI: "}
{msg.content}
))}
setInputValue(e.target.value)}
/>
);
}