Download chat.html from MAIRK/abab: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/MAIRK/abab/resolve/main/chat.html
- Command line
-
hf download hf://MAIRK/abab/chat.html
-
curl -L -o chat.html https://huggingface.co/MAIRK/abab/resolve/main/chat.html
1.05 kB
| <html lang="zh"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>LLaMA2 聊天机器人</title> | |
| </head> | |
| <body> | |
| <h2>🤖 LLaMA2 Chat</h2> | |
| <div id="chat-box" style="border:1px solid #ccc;padding:10px;height:300px;overflow-y:auto;"></div> | |
| <input id="user-input" type="text" placeholder="请输入..." style="width:80%;"> | |
| <button onclick="sendMessage()">发送</button> | |
| <script> | |
| async function sendMessage() { | |
| const input = document.getElementById("user-input").value; | |
| const chat = document.getElementById("chat-box"); | |
| chat.innerHTML += `<div><b>你:</b> ${input}</div>`; | |
| const res = await fetch("http://localhost:8000/generate", { | |
| method: "POST", | |
| headers: {"Content-Type": "application/json"}, | |
| body: JSON.stringify({prompt: input, token: "YOUR_SECURE_TOKEN"}) | |
| }); | |
| const data = await res.json(); | |
| chat.innerHTML += `<div><b>助手:</b> ${data.response}</div>`; | |
| chat.scrollTop = chat.scrollHeight; | |
| } | |
| </script> | |
| </body> | |
| </html> |