Download script.js from Lkonshu/VERO-AI: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/spaces/Lkonshu/VERO-AI/resolve/main/script.js
- Command line
-
hf download hf://spaces/Lkonshu/VERO-AI/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Lkonshu/VERO-AI/resolve/main/script.js
1.53 kB
| const API_URL = | |
| "https://promotional-expert-eligibility-navigator.trycloudflare.com/generate"; | |
| async function sendMessage() { | |
| const input = document.querySelector("#messageInput"); | |
| const chat = document.querySelector("#chat"); | |
| const text = input.value.trim(); | |
| if (!text) return; | |
| addMessage(text, "user"); | |
| input.value = ""; | |
| const loading = addMessage("Arko está pensando...", "ai"); | |
| try { | |
| const response = await fetch(API_URL, { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json" | |
| }, | |
| body: JSON.stringify({ | |
| prompt: text, | |
| max_new_tokens: 300 | |
| }) | |
| }); | |
| const data = await response.json(); | |
| if (!response.ok) { | |
| throw new Error(data.detail || data.error || "API error"); | |
| } | |
| loading.textContent = | |
| data.response || "Arko no devolvió una respuesta."; | |
| } catch (error) { | |
| console.error(error); | |
| loading.textContent = | |
| "No se pudo conectar con Arko Incode 1.0."; | |
| } | |
| } | |
| function addMessage(text, type) { | |
| const chat = document.querySelector("#chat"); | |
| const message = document.createElement("div"); | |
| message.className = `message ${type}`; | |
| message.textContent = text; | |
| chat.appendChild(message); | |
| chat.scrollTop = chat.scrollHeight; | |
| return message; | |
| } | |
| document | |
| .querySelector("#sendButton") | |
| ?.addEventListener("click", sendMessage); | |
| document | |
| .querySelector("#messageInput") | |
| ?.addEventListener("keydown", (event) => { | |
| if (event.key === "Enter") { | |
| sendMessage(); | |
| } | |
| }); |