Spaces:
Runtime error
Runtime error
Download static/script.js from srinuksv/health-assistant: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/spaces/srinuksv/health-assistant/resolve/0669d5d560dda90463174fafc94c3cd01963b09a/static/script.js
- Command line
-
hf download hf://spaces/srinuksv/health-assistant@0669d5d560dda90463174fafc94c3cd01963b09a/static/script.js
-
curl -L -o script.js https://huggingface.co/spaces/srinuksv/health-assistant/resolve/0669d5d560dda90463174fafc94c3cd01963b09a/static/script.js
966 Bytes
| document.getElementById("send-button").addEventListener("click", async () => { | |
| const input = document.getElementById("user-input"); | |
| const message = input.value; | |
| // Add user message to chat history | |
| addMessage("User", message); | |
| // Clear input field | |
| input.value = ""; | |
| // Send message to the backend | |
| const response = await fetch("/chat/", { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json" | |
| }, | |
| body: JSON.stringify({ message }) | |
| }); | |
| const data = await response.json(); | |
| addMessage("Bot", data.response); | |
| }); | |
| function addMessage(sender, message) { | |
| const chatHistory = document.getElementById("chat-history"); | |
| const messageElement = document.createElement("div"); | |
| messageElement.innerHTML = `<strong>${sender}:</strong> ${message}`; | |
| chatHistory.appendChild(messageElement); | |
| chatHistory.scrollTop = chatHistory.scrollHeight; // Scroll to the bottom | |
| } |