Update static/index.html
Browse files- static/index.html +139 -118
static/index.html
CHANGED
@@ -1,133 +1,154 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
</head>
|
67 |
<body>
|
68 |
-
|
69 |
-
<div
|
70 |
-
|
71 |
-
<
|
|
|
|
|
72 |
</div>
|
73 |
-
<div
|
74 |
-
|
75 |
-
<input type="text"
|
76 |
-
<
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
<label for="topP">Top-p (nucleus sampling):</label>
|
81 |
-
<input type="number" id="topP" value="0.95" min="0.1" max="1.0" step="0.05">
|
82 |
</div>
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
-
|
85 |
-
|
|
|
|
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
const messageDiv = document.createElement('div');
|
90 |
-
messageDiv.classList.add(role, 'message');
|
91 |
-
const contentDiv = document.createElement('div');
|
92 |
-
contentDiv.classList.add('message-content');
|
93 |
-
contentDiv.textContent = content;
|
94 |
-
messageDiv.appendChild(contentDiv);
|
95 |
-
chatbox.appendChild(messageDiv);
|
96 |
-
chatbox.scrollTop = chatbox.scrollHeight;
|
97 |
-
}
|
98 |
|
99 |
-
|
100 |
-
const messageInput = document.getElementById('message');
|
101 |
-
const message = messageInput.value;
|
102 |
-
const systemMessage = document.getElementById('systemMessage').value;
|
103 |
-
const maxTokens = parseInt(document.getElementById('maxTokens').value);
|
104 |
-
const temperature = parseFloat(document.getElementById('temperature').value);
|
105 |
-
const topP = parseFloat(document.getElementById('topP').value);
|
106 |
|
107 |
-
|
108 |
-
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
</body>
|
133 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<link rel="stylesheet" href="style.css">
|
8 |
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" />
|
9 |
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
10 |
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
11 |
+
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
|
12 |
+
<title>Document</title>
|
13 |
+
<style>
|
14 |
+
* {
|
15 |
+
padding: 0;
|
16 |
+
margin: 0;
|
17 |
+
font-family: 'Poppins', sans-serif;
|
18 |
+
box-sizing: border-box;
|
19 |
+
}
|
20 |
+
body {
|
21 |
+
width: 100%;
|
22 |
+
height: 100vh;
|
23 |
+
background-color: #33343f;
|
24 |
+
}
|
25 |
+
.chat {
|
26 |
+
display: flex;
|
27 |
+
gap: 20px;
|
28 |
+
padding: 25px;
|
29 |
+
color: #fff;
|
30 |
+
font-size: 15px;
|
31 |
+
font-weight: 300;
|
32 |
+
}
|
33 |
+
.chat img {
|
34 |
+
width: 35px;
|
35 |
+
height: 35px;
|
36 |
+
}
|
37 |
+
.response {
|
38 |
+
background-color: #494b59;
|
39 |
+
}
|
40 |
+
.messagebar {
|
41 |
+
position: fixed;
|
42 |
+
bottom: 0;
|
43 |
+
height: 5rem;
|
44 |
+
width: 100%;
|
45 |
+
display: flex;
|
46 |
+
align-items: center;
|
47 |
+
justify-content: center;
|
48 |
+
border-top: 1px solid #494b59;
|
49 |
+
background-color: #33343f;
|
50 |
+
}
|
51 |
+
.messagebar .bar-wrapper {
|
52 |
+
background-color: #494b59;
|
53 |
+
border-radius: 5px;
|
54 |
+
width: 60vw;
|
55 |
+
padding: 10px;
|
56 |
+
display: flex;
|
57 |
+
align-items: center;
|
58 |
+
justify-content: space-between;
|
59 |
+
}
|
60 |
+
.bar-wrapper input {
|
61 |
+
width: 100%;
|
62 |
+
padding: 5px;
|
63 |
+
border: none;
|
64 |
+
outline: none;
|
65 |
+
font-size: 14px;
|
66 |
+
background: none;
|
67 |
+
color: #ccc;
|
68 |
+
}
|
69 |
+
.bar-wrapper input::placeholder {
|
70 |
+
color: #ccc;
|
71 |
+
}
|
72 |
+
.messagebar button {
|
73 |
+
display: flex;
|
74 |
+
align-items: center;
|
75 |
+
justify-content: center;
|
76 |
+
background: none;
|
77 |
+
border: none;
|
78 |
+
color: #fff;
|
79 |
+
cursor: pointer;
|
80 |
+
}
|
81 |
+
.message-box {
|
82 |
+
height: calc(100vh - 5rem);
|
83 |
+
overflow-y: auto;
|
84 |
+
}
|
85 |
+
</style>
|
86 |
</head>
|
87 |
<body>
|
88 |
+
<div class="chatbox-wrapper">
|
89 |
+
<div class="message-box">
|
90 |
+
<div class="chat response">
|
91 |
+
<img src="img/chatbot.jpg">
|
92 |
+
<span>Hello there! <br> How can I help you today.</span>
|
93 |
+
</div>
|
94 |
</div>
|
95 |
+
<div class="messagebar">
|
96 |
+
<div class="bar-wrapper">
|
97 |
+
<input type="text" placeholder="Enter your message...">
|
98 |
+
<button>
|
99 |
+
<span class="material-symbols-rounded">send</span>
|
100 |
+
</button>
|
101 |
+
</div>
|
|
|
|
|
102 |
</div>
|
103 |
+
</div>
|
104 |
+
<script>
|
105 |
+
const messageBar = document.querySelector(".bar-wrapper input");
|
106 |
+
const sendBtn = document.querySelector(".bar-wrapper button");
|
107 |
+
const messageBox = document.querySelector(".message-box");
|
108 |
|
109 |
+
sendBtn.onclick = async function () {
|
110 |
+
if (messageBar.value.length > 0) {
|
111 |
+
const UserTypedMessage = messageBar.value;
|
112 |
+
messageBar.value = "";
|
113 |
|
114 |
+
let message = `<div class="chat message"><img src="img/user.jpg"><span>${UserTypedMessage}</span></div>`;
|
115 |
+
let response = `<div class="chat response"><img src="img/chatbot.jpg"><span class="new">...</span></div>`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
+
messageBox.insertAdjacentHTML("beforeend", message);
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
+
setTimeout(async () => {
|
120 |
+
messageBox.insertAdjacentHTML("beforeend", response);
|
121 |
|
122 |
+
const requestOptions = {
|
123 |
+
method: "POST",
|
124 |
+
headers: {
|
125 |
+
"Content-Type": "application/x-www-form-urlencoded"
|
126 |
+
},
|
127 |
+
body: new URLSearchParams({
|
128 |
+
prompt: UserTypedMessage,
|
129 |
+
history: "[]",
|
130 |
+
temperature: "0.9",
|
131 |
+
max_new_tokens: "512",
|
132 |
+
top_p: "0.95",
|
133 |
+
repetition_penalty: "1.0"
|
134 |
+
})
|
135 |
+
};
|
136 |
|
137 |
+
try {
|
138 |
+
const res = await fetch("/generate/", requestOptions);
|
139 |
+
const data = await res.json();
|
140 |
+
const ChatBotResponse = document.querySelector(".response .new");
|
141 |
+
ChatBotResponse.innerText = data.response;
|
142 |
+
ChatBotResponse.classList.remove("new");
|
143 |
+
} catch (error) {
|
144 |
+
console.error("Error:", error);
|
145 |
+
const ChatBotResponse = document.querySelector(".response .new");
|
146 |
+
ChatBotResponse.innerText = "Oops! An error occurred. Please try again.";
|
147 |
+
ChatBotResponse.classList.remove("new");
|
148 |
+
}
|
149 |
+
}, 100);
|
150 |
+
}
|
151 |
+
};
|
152 |
+
</script>
|
153 |
</body>
|
154 |
</html>
|