Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,529 +8,6 @@ app = Flask(__name__)
|
|
| 8 |
# Initialize the Hugging Face Inference Client
|
| 9 |
client = InferenceClient("Futuresony/future_ai_12_10_2024.gguf")
|
| 10 |
|
| 11 |
-
# HTML template for the app
|
| 12 |
-
HTML_TEMPLATE = """
|
| 13 |
-
<!DOCTYPE html>
|
| 14 |
-
<html lang="en">
|
| 15 |
-
<head>
|
| 16 |
-
<base href="javascript:" />
|
| 17 |
-
<meta charset="UTF-8">
|
| 18 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 19 |
-
<title>Enhanced Flask Chat Interface with Call Feature</title>
|
| 20 |
-
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
| 21 |
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined&display=swap">
|
| 22 |
-
<style>
|
| 23 |
-
* {
|
| 24 |
-
box-sizing: border-box;
|
| 25 |
-
margin: 0;
|
| 26 |
-
padding: 0;
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
body {
|
| 30 |
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 31 |
-
|
| 32 |
-
display: flex;
|
| 33 |
-
justify-content: center;
|
| 34 |
-
align-items: center;
|
| 35 |
-
height: 90vh;
|
| 36 |
-
margin: 0;
|
| 37 |
-
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
#chat-container {
|
| 42 |
-
width: 1500%;
|
| 43 |
-
max-width: 800px;
|
| 44 |
-
background-color: rgba(255, 255, 255, 0.95);
|
| 45 |
-
padding: 25px;
|
| 46 |
-
border-radius: 20px;
|
| 47 |
-
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
|
| 48 |
-
display: flex;
|
| 49 |
-
flex-direction: column;
|
| 50 |
-
height: 90vh;
|
| 51 |
-
position: relative;
|
| 52 |
-
backdrop-filter: blur(10px);
|
| 53 |
-
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
#chatbox {
|
| 58 |
-
flex: 1;
|
| 59 |
-
overflow-y: auto;
|
| 60 |
-
padding: 15px;
|
| 61 |
-
background-color: #f8f9fa;
|
| 62 |
-
border-radius: 15px;
|
| 63 |
-
font-size: 16px;
|
| 64 |
-
margin-bottom: 20px;
|
| 65 |
-
scroll-behavior: smooth;
|
| 66 |
-
height: 90vh;
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
#chatbox .message {
|
| 71 |
-
padding: 12px 16px;
|
| 72 |
-
border-radius: 15px;
|
| 73 |
-
margin-bottom: 15px;
|
| 74 |
-
word-wrap: break-word;
|
| 75 |
-
font-size: 16px;
|
| 76 |
-
max-width: 80%;
|
| 77 |
-
clear: both;
|
| 78 |
-
position: relative;
|
| 79 |
-
animation: fadeIn 0.3s ease-in-out;
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
#chatbox .user {
|
| 83 |
-
background-color: #007bff;
|
| 84 |
-
color: white;
|
| 85 |
-
float: right;
|
| 86 |
-
border-bottom-right-radius: 5px;
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
#chatbox .ai {
|
| 90 |
-
background-color: #e9ecef;
|
| 91 |
-
color: #333;
|
| 92 |
-
float: left;
|
| 93 |
-
border-bottom-left-radius: 5px;
|
| 94 |
-
}
|
| 95 |
-
|
| 96 |
-
#user-input-container {
|
| 97 |
-
position: relative;
|
| 98 |
-
display: flex;
|
| 99 |
-
align-items: center;
|
| 100 |
-
padding: 15px;
|
| 101 |
-
flex-wrap: wrap;
|
| 102 |
-
}
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
#user-input {
|
| 106 |
-
flex: 1;
|
| 107 |
-
padding: 12px 15px;
|
| 108 |
-
border: none;
|
| 109 |
-
border-radius: 10px;
|
| 110 |
-
font-size: 16px;
|
| 111 |
-
background-color: white;
|
| 112 |
-
transition: all 0.3s ease;
|
| 113 |
-
padding-right: 45px;
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
#user-input:focus {
|
| 118 |
-
outline: none;
|
| 119 |
-
box-shadow: 0 0 0 2px #007bff33;
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
button {
|
| 124 |
-
padding: 12px;
|
| 125 |
-
background-color: #007bff;
|
| 126 |
-
color: white;
|
| 127 |
-
border: none;
|
| 128 |
-
border-radius: 10px;
|
| 129 |
-
cursor: pointer;
|
| 130 |
-
font-size: 16px;
|
| 131 |
-
transition: all 0.3s ease;
|
| 132 |
-
display: flex;
|
| 133 |
-
align-items: center;
|
| 134 |
-
gap: 5px;
|
| 135 |
-
}
|
| 136 |
-
|
| 137 |
-
button:hover {
|
| 138 |
-
background-color: #0056b3;
|
| 139 |
-
transform: translateY(-2px);
|
| 140 |
-
}
|
| 141 |
-
|
| 142 |
-
.mic-icon, .call-icon {
|
| 143 |
-
font-size: 24px;
|
| 144 |
-
cursor: pointer;
|
| 145 |
-
color: #555;
|
| 146 |
-
transition: all 0.3s ease;
|
| 147 |
-
padding: 8px;
|
| 148 |
-
border-radius: 50%;
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
.mic-icon:hover, .call-icon:hover {
|
| 152 |
-
|
| 153 |
-
}
|
| 154 |
-
|
| 155 |
-
#call-ui {
|
| 156 |
-
display: none;
|
| 157 |
-
position: absolute;
|
| 158 |
-
top: 50%;
|
| 159 |
-
left: 50%;
|
| 160 |
-
transform: translate(-50%, -50%);
|
| 161 |
-
background-color: white;
|
| 162 |
-
padding: 30px;
|
| 163 |
-
border-radius: 20px;
|
| 164 |
-
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
| 165 |
-
text-align: center;
|
| 166 |
-
z-index: 1000;
|
| 167 |
-
}
|
| 168 |
-
|
| 169 |
-
#call-ui p {
|
| 170 |
-
font-size: 18px;
|
| 171 |
-
margin: 15px 0;
|
| 172 |
-
color: #333;
|
| 173 |
-
}
|
| 174 |
-
|
| 175 |
-
#timer {
|
| 176 |
-
font-size: 24px;
|
| 177 |
-
font-weight: bold;
|
| 178 |
-
color: #007bff;
|
| 179 |
-
margin-top: 15px;
|
| 180 |
-
}
|
| 181 |
-
|
| 182 |
-
.bottom-icons {
|
| 183 |
-
display: flex;
|
| 184 |
-
justify-content: center;
|
| 185 |
-
gap: 15px;
|
| 186 |
-
position: absolute;
|
| 187 |
-
bottom: 1px;
|
| 188 |
-
left: 50%;
|
| 189 |
-
transform: translateX(-50%);
|
| 190 |
-
}
|
| 191 |
-
|
| 192 |
-
.call-icon {
|
| 193 |
-
color: green;
|
| 194 |
-
}
|
| 195 |
-
}
|
| 196 |
-
.icons, .navigation {
|
| 197 |
-
display: inline-flex;
|
| 198 |
-
align-items: center;
|
| 199 |
-
gap: 10px;
|
| 200 |
-
margin-top: 5px;
|
| 201 |
-
}
|
| 202 |
-
.navigation {
|
| 203 |
-
display: inline-flex;
|
| 204 |
-
align-items: center;
|
| 205 |
-
gap: 10px;
|
| 206 |
-
margin-left: 10px;
|
| 207 |
-
font-size: 14px;
|
| 208 |
-
color: #666;
|
| 209 |
-
}
|
| 210 |
-
.navigation span {
|
| 211 |
-
padding: 0 5px;
|
| 212 |
-
}
|
| 213 |
-
|
| 214 |
-
.status-dot {
|
| 215 |
-
display: inline-block;
|
| 216 |
-
width: 10px;
|
| 217 |
-
height: 10px;
|
| 218 |
-
background-color: green; /* Online indicator color */
|
| 219 |
-
border-radius: 50%;
|
| 220 |
-
margin-right: 5px;
|
| 221 |
-
}
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
@keyframes typingAnimation {
|
| 226 |
-
0%, 100% {
|
| 227 |
-
transform: translateY(0);
|
| 228 |
-
}
|
| 229 |
-
50% {
|
| 230 |
-
transform: translateY(-10px);
|
| 231 |
-
}
|
| 232 |
-
}
|
| 233 |
-
|
| 234 |
-
.typing-dot {
|
| 235 |
-
width: 8px;
|
| 236 |
-
height: 8px;
|
| 237 |
-
background-color: #007bff;
|
| 238 |
-
border-radius: 50%;
|
| 239 |
-
display: inline-block;
|
| 240 |
-
animation: typingAnimation 1s infinite ease-in-out;
|
| 241 |
-
margin-right: 5px;
|
| 242 |
-
}
|
| 243 |
-
|
| 244 |
-
.typing-dot:nth-child(2) {
|
| 245 |
-
animation-delay: 0.2s;
|
| 246 |
-
}
|
| 247 |
-
|
| 248 |
-
.typing-dot:nth-child(3) {
|
| 249 |
-
animation-delay: 0.4s;
|
| 250 |
-
}
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
#chatbox::-webkit-scrollbar {
|
| 255 |
-
width: 8px;
|
| 256 |
-
}
|
| 257 |
-
|
| 258 |
-
#chatbox::-webkit-scrollbar-track {
|
| 259 |
-
background: #f1f1f1;
|
| 260 |
-
border-radius: 4px;
|
| 261 |
-
}
|
| 262 |
-
|
| 263 |
-
#chatbox::-webkit-scrollbar-thumb {
|
| 264 |
-
background: #888;
|
| 265 |
-
border-radius: 4px;
|
| 266 |
-
}
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
</style>
|
| 270 |
-
</head>
|
| 271 |
-
<body>
|
| 272 |
-
<div id="chat-container">
|
| 273 |
-
<div class="header">
|
| 274 |
-
<h1>Chat Assistant</h1>
|
| 275 |
-
<div class="status-indicator">
|
| 276 |
-
<span class="status-dot"></span>
|
| 277 |
-
Online
|
| 278 |
-
</div>
|
| 279 |
-
</div>
|
| 280 |
-
|
| 281 |
-
<div id="chatbox">
|
| 282 |
-
<div id="typing-indicator" style="display: none;">
|
| 283 |
-
<div class="typing-dot"></div>
|
| 284 |
-
<div class="typing-dot"></div>
|
| 285 |
-
<div class="typing-dot"></div>
|
| 286 |
-
</div>
|
| 287 |
-
</div>
|
| 288 |
-
|
| 289 |
-
<div id="user-input-container">
|
| 290 |
-
<input type="text" id="user-input" placeholder="Type your message here..." />
|
| 291 |
-
<span class="material-icons send-icon" onclick="sendMessage()">send</span>
|
| 292 |
-
</div>
|
| 293 |
-
|
| 294 |
-
<div class="bottom-icons">
|
| 295 |
-
<span class="material-icons mic-icon" id="mic-icon">mic</span>
|
| 296 |
-
<span class="material-icons call-icon" id="call-icon">call</span>
|
| 297 |
-
</div>
|
| 298 |
-
</div>
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
<script>
|
| 302 |
-
let isRecording = false;
|
| 303 |
-
let recognition;
|
| 304 |
-
let responsesHistory = {}; // Holds all responses per prompt
|
| 305 |
-
let currentIndex = {}; // Track current response index
|
| 306 |
-
|
| 307 |
-
function initSpeechRecognition() {
|
| 308 |
-
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
| 309 |
-
recognition = new SpeechRecognition();
|
| 310 |
-
recognition.lang = 'en-US';
|
| 311 |
-
recognition.interimResults = false;
|
| 312 |
-
recognition.maxAlternatives = 1;
|
| 313 |
-
|
| 314 |
-
recognition.onresult = function(event) {
|
| 315 |
-
const transcript = event.results[0][0].transcript;
|
| 316 |
-
sendMessageFromVoice(transcript);
|
| 317 |
-
};
|
| 318 |
-
recognition.onerror = function(event) {
|
| 319 |
-
console.log("Speech recognition error:", event.error);
|
| 320 |
-
};
|
| 321 |
-
}
|
| 322 |
-
|
| 323 |
-
const micIcon = document.getElementById('mic-icon');
|
| 324 |
-
micIcon.addEventListener('mousedown', function() {
|
| 325 |
-
isRecording = true;
|
| 326 |
-
micIcon.textContent = 'mic_off';
|
| 327 |
-
recognition.start();
|
| 328 |
-
});
|
| 329 |
-
|
| 330 |
-
micIcon.addEventListener('mouseup', function() {
|
| 331 |
-
isRecording = false;
|
| 332 |
-
micIcon.textContent = 'mic';
|
| 333 |
-
recognition.stop();
|
| 334 |
-
});
|
| 335 |
-
|
| 336 |
-
function appendMessage(text, className) {
|
| 337 |
-
let chatbox = document.getElementById('chatbox');
|
| 338 |
-
let messageDiv = document.createElement('div');
|
| 339 |
-
messageDiv.className = 'message ' + className;
|
| 340 |
-
messageDiv.innerHTML = text;
|
| 341 |
-
chatbox.appendChild(messageDiv);
|
| 342 |
-
chatbox.scrollTop = chatbox.scrollHeight;
|
| 343 |
-
}
|
| 344 |
-
|
| 345 |
-
function sendMessageFromVoice(message) {
|
| 346 |
-
appendMessage(message, 'user');
|
| 347 |
-
fetchMessageFromAI(message);
|
| 348 |
-
}
|
| 349 |
-
|
| 350 |
-
function sendMessage() {
|
| 351 |
-
let userInput = document.getElementById('user-input');
|
| 352 |
-
let message = userInput.value.trim();
|
| 353 |
-
if (message === '') return;
|
| 354 |
-
appendMessage(message, 'user');
|
| 355 |
-
userInput.value = '';
|
| 356 |
-
fetchMessageFromAI(message);
|
| 357 |
-
}
|
| 358 |
-
|
| 359 |
-
function fetchMessageFromAI(message) {
|
| 360 |
-
document.getElementById('typing-indicator').style.display = 'flex';
|
| 361 |
-
|
| 362 |
-
fetch('/message', {
|
| 363 |
-
method: 'POST',
|
| 364 |
-
headers: {
|
| 365 |
-
'Content-Type': 'application/json',
|
| 366 |
-
},
|
| 367 |
-
body: JSON.stringify({ text: message })
|
| 368 |
-
})
|
| 369 |
-
.then(response => {
|
| 370 |
-
if (!response.ok) {
|
| 371 |
-
throw new Error(`Server error: ${response.statusText}`);
|
| 372 |
-
}
|
| 373 |
-
return response.json();
|
| 374 |
-
})
|
| 375 |
-
.then(data => {
|
| 376 |
-
document.getElementById('typing-indicator').style.display = 'none';
|
| 377 |
-
|
| 378 |
-
if (data.response) {
|
| 379 |
-
addAIResponse(data.response, message);
|
| 380 |
-
} else {
|
| 381 |
-
console.error("No response from the server.");
|
| 382 |
-
}
|
| 383 |
-
})
|
| 384 |
-
.catch(error => {
|
| 385 |
-
document.getElementById('typing-indicator').style.display = 'none';
|
| 386 |
-
console.error('Error:', error);
|
| 387 |
-
appendMessage("An error occurred. Please try again later.", 'ai');
|
| 388 |
-
});
|
| 389 |
-
}
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
function addAIResponse(responseText, userPrompt) {
|
| 394 |
-
const responseId = Date.now();
|
| 395 |
-
responsesHistory[responseId] = [responseText];
|
| 396 |
-
currentIndex[responseId] = 0;
|
| 397 |
-
renderAIResponse(responseText, responseId, userPrompt);
|
| 398 |
-
}
|
| 399 |
-
|
| 400 |
-
function renderAIResponse(responseText, responseId, userPrompt) {
|
| 401 |
-
let chatbox = document.getElementById('chatbox');
|
| 402 |
-
let messageDiv = document.createElement('div');
|
| 403 |
-
messageDiv.className = 'message ai';
|
| 404 |
-
messageDiv.dataset.responseId = responseId;
|
| 405 |
-
messageDiv.dataset.userPrompt = userPrompt; // Store the prompt
|
| 406 |
-
|
| 407 |
-
let responseTextDiv = document.createElement('div');
|
| 408 |
-
responseTextDiv.className = 'response-text';
|
| 409 |
-
responseTextDiv.innerHTML = responseText;
|
| 410 |
-
messageDiv.appendChild(responseTextDiv);
|
| 411 |
-
|
| 412 |
-
let iconsDiv = document.createElement('div');
|
| 413 |
-
iconsDiv.className = 'icons';
|
| 414 |
-
|
| 415 |
-
let speakerIcon = document.createElement('span');
|
| 416 |
-
speakerIcon.className = 'material-icons';
|
| 417 |
-
speakerIcon.innerText = 'volume_up';
|
| 418 |
-
speakerIcon.onclick = () => speakText(responseId);
|
| 419 |
-
|
| 420 |
-
let copyIcon = document.createElement('span');
|
| 421 |
-
copyIcon.className = 'material-icons';
|
| 422 |
-
copyIcon.innerText = 'content_copy';
|
| 423 |
-
copyIcon.onclick = () => copyResponse(responseId);
|
| 424 |
-
|
| 425 |
-
let regenerateIcon = document.createElement('span');
|
| 426 |
-
regenerateIcon.className = 'material-icons';
|
| 427 |
-
regenerateIcon.innerText = 'replay';
|
| 428 |
-
regenerateIcon.onclick = () => regenerateResponse(responseId, responseTextDiv, iconsDiv);
|
| 429 |
-
|
| 430 |
-
iconsDiv.appendChild(speakerIcon);
|
| 431 |
-
iconsDiv.appendChild(copyIcon);
|
| 432 |
-
iconsDiv.appendChild(regenerateIcon);
|
| 433 |
-
messageDiv.appendChild(iconsDiv);
|
| 434 |
-
chatbox.appendChild(messageDiv);
|
| 435 |
-
chatbox.scrollTop = chatbox.scrollHeight;
|
| 436 |
-
}
|
| 437 |
-
|
| 438 |
-
function regenerateResponse(responseId, responseTextDiv, iconsDiv) {
|
| 439 |
-
responseTextDiv.innerHTML = 'Generating new response...';
|
| 440 |
-
|
| 441 |
-
// Get the original prompt from the dataset
|
| 442 |
-
const messageDiv = document.querySelector(`[data-response-id="${responseId}"]`);
|
| 443 |
-
const originalPrompt = messageDiv.dataset.userPrompt;
|
| 444 |
-
|
| 445 |
-
fetch('/message', {
|
| 446 |
-
method: 'POST',
|
| 447 |
-
headers: {
|
| 448 |
-
'Content-Type': 'application/json',
|
| 449 |
-
},
|
| 450 |
-
body: JSON.stringify({ text: originalPrompt }) // Use the original prompt
|
| 451 |
-
})
|
| 452 |
-
.then(response => response.json())
|
| 453 |
-
.then(data => {
|
| 454 |
-
if (data.response) {
|
| 455 |
-
responsesHistory[responseId].push(data.response);
|
| 456 |
-
currentIndex[responseId] = responsesHistory[responseId].length - 1;
|
| 457 |
-
displayUpdatedResponse(responseId, data.response, iconsDiv);
|
| 458 |
-
} else {
|
| 459 |
-
responseTextDiv.innerHTML = 'Error generating response';
|
| 460 |
-
}
|
| 461 |
-
})
|
| 462 |
-
.catch(error => {
|
| 463 |
-
console.error('Error:', error);
|
| 464 |
-
responseTextDiv.innerHTML = 'Error generating response';
|
| 465 |
-
});
|
| 466 |
-
}
|
| 467 |
-
|
| 468 |
-
function displayUpdatedResponse(responseId, newResponse, iconsDiv) {
|
| 469 |
-
let messageDiv = document.querySelector(`[data-response-id="${responseId}"]`);
|
| 470 |
-
let responseTextDiv = messageDiv.querySelector('.response-text');
|
| 471 |
-
responseTextDiv.innerHTML = newResponse;
|
| 472 |
-
|
| 473 |
-
// Remove existing navigation if present
|
| 474 |
-
const existingNav = messageDiv.querySelector('.navigation');
|
| 475 |
-
if (existingNav) {
|
| 476 |
-
existingNav.remove();
|
| 477 |
-
}
|
| 478 |
-
|
| 479 |
-
let navigationDiv = document.createElement('div');
|
| 480 |
-
navigationDiv.className = 'navigation';
|
| 481 |
-
iconsDiv.appendChild(navigationDiv);
|
| 482 |
-
|
| 483 |
-
let backIcon = document.createElement('span');
|
| 484 |
-
backIcon.className = 'material-icons';
|
| 485 |
-
backIcon.innerText = 'arrow_back';
|
| 486 |
-
backIcon.onclick = () => navigateResponse(responseId, -1, responseTextDiv, navigationDiv);
|
| 487 |
-
|
| 488 |
-
let nextIcon = document.createElement('span');
|
| 489 |
-
nextIcon.className = 'material-icons';
|
| 490 |
-
nextIcon.innerText = 'arrow_forward';
|
| 491 |
-
nextIcon.onclick = () => navigateResponse(responseId, 1, responseTextDiv, navigationDiv);
|
| 492 |
-
|
| 493 |
-
let responseIndexText = document.createElement('span');
|
| 494 |
-
responseIndexText.className = 'response-index';
|
| 495 |
-
|
| 496 |
-
navigationDiv.appendChild(backIcon);
|
| 497 |
-
navigationDiv.appendChild(responseIndexText);
|
| 498 |
-
navigationDiv.appendChild(nextIcon);
|
| 499 |
-
|
| 500 |
-
updateResponseIndex(responseId, responseIndexText);
|
| 501 |
-
}
|
| 502 |
-
|
| 503 |
-
function navigateResponse(responseId, direction, responseTextDiv, navigationDiv) {
|
| 504 |
-
currentIndex[responseId] += direction;
|
| 505 |
-
currentIndex[responseId] = Math.max(0, Math.min(currentIndex[responseId], responsesHistory[responseId].length - 1));
|
| 506 |
-
responseTextDiv.innerHTML = responsesHistory[responseId][currentIndex[responseId]];
|
| 507 |
-
updateResponseIndex(responseId, navigationDiv.querySelector('.response-index'));
|
| 508 |
-
}
|
| 509 |
-
|
| 510 |
-
function updateResponseIndex(responseId, responseIndexText) {
|
| 511 |
-
responseIndexText.innerText = `${currentIndex[responseId] + 1}/${responsesHistory[responseId].length}`;
|
| 512 |
-
}
|
| 513 |
-
|
| 514 |
-
// Updated function to speak the current response
|
| 515 |
-
function speakText(responseId) {
|
| 516 |
-
const text = responsesHistory[responseId][currentIndex[responseId]];
|
| 517 |
-
const utterance = new SpeechSynthesisUtterance(text);
|
| 518 |
-
speechSynthesis.speak(utterance);
|
| 519 |
-
}
|
| 520 |
-
|
| 521 |
-
// Updated function to copy the current response
|
| 522 |
-
function copyResponse(responseId) {
|
| 523 |
-
const text = responsesHistory[responseId][currentIndex[responseId]];
|
| 524 |
-
navigator.clipboard.writeText(text);
|
| 525 |
-
alert("Copied: " + text);
|
| 526 |
-
}
|
| 527 |
-
|
| 528 |
-
document.addEventListener('DOMContentLoaded', initSpeechRecognition);
|
| 529 |
-
</script>
|
| 530 |
-
</body>
|
| 531 |
-
</html>
|
| 532 |
-
"""
|
| 533 |
-
|
| 534 |
@app.route("/")
|
| 535 |
def home():
|
| 536 |
return HTML_TEMPLATE
|
|
@@ -571,5 +48,4 @@ function fetchMessageFromAI(message) {
|
|
| 571 |
if __name__ == "__main__":
|
| 572 |
# Use PORT environment variable or default to 7860
|
| 573 |
port = int(os.getenv("PORT", 7860))
|
| 574 |
-
app.run(host="0.0.0.0", port=port)
|
| 575 |
-
|
|
|
|
| 8 |
# Initialize the Hugging Face Inference Client
|
| 9 |
client = InferenceClient("Futuresony/future_ai_12_10_2024.gguf")
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
@app.route("/")
|
| 12 |
def home():
|
| 13 |
return HTML_TEMPLATE
|
|
|
|
| 48 |
if __name__ == "__main__":
|
| 49 |
# Use PORT environment variable or default to 7860
|
| 50 |
port = int(os.getenv("PORT", 7860))
|
| 51 |
+
app.run(host="0.0.0.0", port=port)
|
|
|