Spaces:
Running
Running
Commit
·
719a9b0
1
Parent(s):
aed8fda
Update index.html
Browse files- index.html +77 -17
index.html
CHANGED
@@ -1,19 +1,79 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Hugging Face Chatbot</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: Arial, sans-serif;
|
10 |
+
background-color: #f5f5f5;
|
11 |
+
display: flex;
|
12 |
+
justify-content: center;
|
13 |
+
align-items: center;
|
14 |
+
height: 100vh;
|
15 |
+
margin: 0;
|
16 |
+
}
|
17 |
+
.chat-container {
|
18 |
+
background-color: #ffffff;
|
19 |
+
border-radius: 5px;
|
20 |
+
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
|
21 |
+
width: 80%;
|
22 |
+
max-width: 500px;
|
23 |
+
padding: 20px;
|
24 |
+
}
|
25 |
+
input[type="text"] {
|
26 |
+
border: 1px solid #cccccc;
|
27 |
+
border-radius: 3px;
|
28 |
+
padding: 10px;
|
29 |
+
width: 100%;
|
30 |
+
box-sizing: border-box;
|
31 |
+
margin-bottom: 10px;
|
32 |
+
}
|
33 |
+
button {
|
34 |
+
background-color: #007bff;
|
35 |
+
border: none;
|
36 |
+
border-radius: 3px;
|
37 |
+
color: #ffffff;
|
38 |
+
cursor: pointer;
|
39 |
+
padding: 10px;
|
40 |
+
width: 100%;
|
41 |
+
}
|
42 |
+
.response {
|
43 |
+
margin-top: 20px;
|
44 |
+
}
|
45 |
+
</style>
|
46 |
+
</head>
|
47 |
+
<body>
|
48 |
+
<div class="chat-container">
|
49 |
+
<input type="text" id="user-input" placeholder="Type your message" />
|
50 |
+
<button id="submit">Send</button>
|
51 |
+
<div class="response" id="response"></div>
|
52 |
+
</div>
|
53 |
+
|
54 |
+
<script>
|
55 |
+
async function query(data) {
|
56 |
+
const response = await fetch(
|
57 |
+
"https://api-inference.huggingface.co/models/decapoda-research/llama-7b-hf",
|
58 |
+
{
|
59 |
+
headers: { Authorization: "Bearer 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" },
|
60 |
+
method: "POST",
|
61 |
+
body: JSON.stringify(data),
|
62 |
+
}
|
63 |
+
);
|
64 |
+
const result = await response.json();
|
65 |
+
return result;
|
66 |
+
}
|
67 |
+
|
68 |
+
document.getElementById("submit").addEventListener("click", async () => {
|
69 |
+
const userInput = document.getElementById("user-input").value;
|
70 |
+
const responseContainer = document.getElementById("response");
|
71 |
+
|
72 |
+
if (userInput) {
|
73 |
+
const response = await query({ "inputs": userInput });
|
74 |
+
responseContainer.innerHTML = response.generated_text;
|
75 |
+
}
|
76 |
+
});
|
77 |
+
</script>
|
78 |
+
</body>
|
79 |
</html>
|