Spaces:
Running
Running
File size: 7,442 Bytes
8891be8 834001a c13e300 4531016 1ff88ce 4531016 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 834001a 1ff88ce 6075594 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 1ff88ce c13e300 4531016 1ff88ce 4531016 1ff88ce 4531016 1ff88ce 4531016 1ff88ce 4531016 c13e300 1ff88ce 4531016 c13e300 4531016 1ff88ce 4531016 c13e300 1ff88ce c13e300 4531016 1ff88ce 4531016 c13e300 1ff88ce 732ddfe 8891be8 dd124d4 |
1 2 3 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
<!-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>AI Chatbot</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
height: 100vh;
display: flex;
flex-direction: column;
background-color: #f4f4f4;
transition: background-color 0.3s, color 0.3s;
}
body.dark-mode {
background-color: #121212;
color: white;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
background-color: #333;
color: white;
}
header h1 {
margin: 0;
font-size: 1.5em;
}
.controls {
display: flex;
gap: 10px;
}
#chat-box {
flex-grow: 1;
padding: 20px;
overflow-y: auto;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
background-color: #fff;
}
body.dark-mode #chat-box {
background-color: #1e1e1e;
}
#input-container {
display: flex;
padding: 10px;
background-color: #f9f9f9;
border-top: 1px solid #ccc;
}
body.dark-mode #input-container {
background-color: #1a1a1a;
}
#user-input {
flex-grow: 1;
padding: 10px;
font-size: 1em;
border: 1px solid #ccc;
border-radius: 4px;
}
#send-btn {
margin-left: 10px;
padding: 10px 15px;
font-size: 1em;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
#send-btn:hover {
background-color: #45a049;
}
.message {
margin: 10px 0;
}
.message strong {
display: inline-block;
width: 60px;
}
</style>
</head>
<body>
<header>
<h1 style="text-align: center; font-family: 'Segoe UI', sans-serif; font-size: 2.5rem;">
π€ AI Chatbot <span style="font-size: 2rem;">π§ </span>
</h1>
<div class="controls">
<button onclick="toggleMode()">π Theme</button>
<button onclick="clearChat()">ποΈ Clear</button>
<button onclick="exportChat()">π Export</button>
</div>
</header>
<div id="chat-box"></div>
<div id="input-container">
<input type="text" id="user-input" placeholder="Type a message..." onkeypress="handleEnter(event)">
<button id="send-btn" onclick="sendMessage()">Send</button>
</div>
<script>
function handleEnter(e) {
if (e.key === 'Enter') sendMessage();
}
async function sendMessage() {
const userInput = document.getElementById("user-input").value.trim();
const chatBox = document.getElementById("chat-box");
if (!userInput) return;
chatBox.innerHTML += `<div class="message"><strong>You:</strong> ${userInput}</div>`;
scrollToBottom();
document.getElementById("user-input").value = "";
const response = await fetch("/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ message: userInput })
});
const data = await response.json();
const reply = data.reply || "Error in response";
chatBox.innerHTML += `<div class="message"><strong>Bot:</strong> ${reply}</div>`;
scrollToBottom();
}
function toggleMode() {
document.body.classList.toggle("dark-mode");
}
function clearChat() {
document.getElementById("chat-box").innerHTML = "";
}
function scrollToBottom() {
const chatBox = document.getElementById("chat-box");
chatBox.scrollTop = chatBox.scrollHeight;
}
function exportChat() {
const chat = document.getElementById("chat-box").innerText;
const blob = new Blob([chat], { type: "text/plain" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "chat_history.txt";
a.click();
URL.revokeObjectURL(url);
}
</script>
</body>
</html> -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Apollo Tyres AI Assistant</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 0;
}
header {
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
background-color: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
header img {
height: 40px;
margin-right: 10px;
}
header h1 {
font-size: 1.8rem;
color: #4B0082;
margin: 0;
}
#chat-box {
width: 90%;
max-width: 1000px;
height: 600px;
margin: 20px auto;
padding: 15px;
background: white;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.2);
overflow-y: auto;
}
#user-input {
width: 70%;
padding: 10px;
font-size: 1rem;
}
button {
padding: 10px 20px;
font-size: 1rem;
background-color: #4B0082;
color: white;
border: none;
cursor: pointer;
margin-left: 10px;
}
#controls {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 20px;
}
</style>
</head>
<body>
<header>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Apollo_Tyres_Logo.svg/512px-Apollo_Tyres_Logo.svg.png" alt="Apollo Tyres Logo">
<h1>Apollo Tyres AI Assistant π§ </h1>
</header>
<div id="chat-box">
<p><b>Apollo AI:</b> π Hello! Iβm your Apollo Tyres virtual assistant. How can I help you today?</p>
</div>
<div id="controls">
<input type="text" id="user-input" placeholder="Type your message...">
<button onclick="sendMessage()">Send</button>
<button onclick="clearChat()">Clear</button>
<button onclick="exportChat()">Export</button>
</div>
<script>
const chatBox = document.getElementById("chat-box");
async function sendMessage() {
let userInput = document.getElementById("user-input").value;
if (!userInput.trim()) return;
chatBox.innerHTML += `<p><b>You:</b> ${userInput}</p>`;
const response = await fetch("/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ message: userInput }),
});
const data = await response.json();
chatBox.innerHTML += `<p><b>Apollo AI:</b> ${data.reply || "Error in response"}</p>`;
document.getElementById("user-input").value = "";
// Auto-scroll
chatBox.scrollTop = chatBox.scrollHeight;
}
function clearChat() {
chatBox.innerHTML = `<p><b>Apollo AI:</b> π Hello! Iβm your Apollo Tyres virtual assistant. How can I help you today?</p>`;
}
function exportChat() {
const text = chatBox.innerText;
const blob = new Blob([text], { type: "text/plain" });
const a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = "apollo_chat_history.txt";
a.click();
}
// Allow Enter key to send message
document.getElementById("user-input").addEventListener("keydown", function (e) {
if (e.key === "Enter") sendMessage();
});
</script>
</body>
</html>
|