Spaces:
Paused
Paused
Download static/script.js from kzsnlsa/Medbot-chat: direct link, hf CLI and curl.
- Browser
- Download file 794 Bytes
-
https://huggingface.co/spaces/kzsnlsa/Medbot-chat/resolve/main/static/script.js
- Command line
-
hf download hf://spaces/kzsnlsa/Medbot-chat/static/script.js
-
curl -L -o script.js https://huggingface.co/spaces/kzsnlsa/Medbot-chat/resolve/main/static/script.js
794 Bytes
| async function sendMessage() { | |
| const input = document.getElementById("user-input"); | |
| const chatBox = document.getElementById("chat-box"); | |
| const userText = input.value.trim(); | |
| if (!userText) return; | |
| chatBox.innerHTML += `<div class="message user"><b>You:</b> ${userText}</div>`; | |
| input.value = ""; | |
| chatBox.scrollTop = chatBox.scrollHeight; | |
| const response = await fetch("/generate", { | |
| method: "POST", | |
| headers: {"Content-Type": "application/json"}, | |
| body: JSON.stringify({prompt: userText}) | |
| }); | |
| const data = await response.json(); | |
| const botText = data.response || "Error generating response."; | |
| chatBox.innerHTML += `<div class="message bot"><b>MedBot:</b> ${botText}</div>`; | |
| chatBox.scrollTop = chatBox.scrollHeight; | |
| } | |