Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -153,7 +153,6 @@
|
|
153 |
/>
|
154 |
</div>
|
155 |
<button
|
156 |
-
onclick="sendMessage()"
|
157 |
id="send-button"
|
158 |
class="px-6 py-3 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-600 disabled:cursor-not-allowed rounded-lg transition-colors flex items-center gap-2"
|
159 |
>
|
@@ -218,19 +217,31 @@
|
|
218 |
|
219 |
function setupEventListeners() {
|
220 |
// Model selection
|
221 |
-
document.getElementById('model-select')
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
226 |
|
227 |
// Enter key to send message
|
228 |
-
document.getElementById('message-input')
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
}
|
235 |
|
236 |
async function sendMessage() {
|
@@ -411,14 +422,16 @@
|
|
411 |
const button = document.getElementById('send-button');
|
412 |
const input = document.getElementById('message-input');
|
413 |
|
414 |
-
if (
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
|
|
|
|
422 |
}
|
423 |
}
|
424 |
|
|
|
153 |
/>
|
154 |
</div>
|
155 |
<button
|
|
|
156 |
id="send-button"
|
157 |
class="px-6 py-3 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-600 disabled:cursor-not-allowed rounded-lg transition-colors flex items-center gap-2"
|
158 |
>
|
|
|
217 |
|
218 |
function setupEventListeners() {
|
219 |
// Model selection
|
220 |
+
const modelSelect = document.getElementById('model-select');
|
221 |
+
if (modelSelect) {
|
222 |
+
modelSelect.addEventListener('change', function(e) {
|
223 |
+
selectedModel = e.target.value;
|
224 |
+
document.getElementById('model-id').textContent = selectedModel;
|
225 |
+
document.getElementById('current-model-name').textContent = models[selectedModel];
|
226 |
+
});
|
227 |
+
}
|
228 |
|
229 |
// Enter key to send message
|
230 |
+
const messageInput = document.getElementById('message-input');
|
231 |
+
if (messageInput) {
|
232 |
+
messageInput.addEventListener('keydown', function(e) {
|
233 |
+
if (e.key === 'Enter' && !e.shiftKey) {
|
234 |
+
e.preventDefault();
|
235 |
+
sendMessage();
|
236 |
+
}
|
237 |
+
});
|
238 |
+
}
|
239 |
+
|
240 |
+
// Send button click
|
241 |
+
const sendButton = document.getElementById('send-button');
|
242 |
+
if (sendButton) {
|
243 |
+
sendButton.addEventListener('click', sendMessage);
|
244 |
+
}
|
245 |
}
|
246 |
|
247 |
async function sendMessage() {
|
|
|
422 |
const button = document.getElementById('send-button');
|
423 |
const input = document.getElementById('message-input');
|
424 |
|
425 |
+
if (button && input) {
|
426 |
+
if (loading) {
|
427 |
+
button.disabled = true;
|
428 |
+
input.disabled = true;
|
429 |
+
button.innerHTML = '<div class="w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"></div> Loading...';
|
430 |
+
} else {
|
431 |
+
button.disabled = false;
|
432 |
+
input.disabled = false;
|
433 |
+
button.innerHTML = '<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 24 24"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg> Send';
|
434 |
+
}
|
435 |
}
|
436 |
}
|
437 |
|