Upload chat.html
Browse files<!DOCTYPE html>
<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>
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="zh">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>LLaMA2 聊天机器人</title>
|
| 6 |
+
</head>
|
| 7 |
+
<body>
|
| 8 |
+
<h2>🤖 LLaMA2 Chat</h2>
|
| 9 |
+
<div id="chat-box" style="border:1px solid #ccc;padding:10px;height:300px;overflow-y:auto;"></div>
|
| 10 |
+
<input id="user-input" type="text" placeholder="请输入..." style="width:80%;">
|
| 11 |
+
<button onclick="sendMessage()">发送</button>
|
| 12 |
+
|
| 13 |
+
<script>
|
| 14 |
+
async function sendMessage() {
|
| 15 |
+
const input = document.getElementById("user-input").value;
|
| 16 |
+
const chat = document.getElementById("chat-box");
|
| 17 |
+
chat.innerHTML += `<div><b>你:</b> ${input}</div>`;
|
| 18 |
+
const res = await fetch("http://localhost:8000/generate", {
|
| 19 |
+
method: "POST",
|
| 20 |
+
headers: {"Content-Type": "application/json"},
|
| 21 |
+
body: JSON.stringify({prompt: input, token: "YOUR_SECURE_TOKEN"})
|
| 22 |
+
});
|
| 23 |
+
const data = await res.json();
|
| 24 |
+
chat.innerHTML += `<div><b>助手:</b> ${data.response}</div>`;
|
| 25 |
+
chat.scrollTop = chat.scrollHeight;
|
| 26 |
+
}
|
| 27 |
+
</script>
|
| 28 |
+
</body>
|
| 29 |
+
</html>
|