Spaces:
Running
Running
Update index.html
Browse files- index.html +11 -15
index.html
CHANGED
@@ -279,11 +279,7 @@
|
|
279 |
<div class="flex-grow overflow-y-auto px-4 sidebar-content">
|
280 |
<h3 class="text-sm font-semibold text-gray-400 mb-2">Saved Chats</h3>
|
281 |
<div id="chatsList" class="space-y-2">
|
282 |
-
|
283 |
-
<div class="chat-file hover:bg-gray-700 p-2 rounded-lg cursor-pointer transition" data-file="{{ chat }}">
|
284 |
-
<i class="fas fa-comment-alt mr-2"></i>{{ chat }}
|
285 |
-
</div>
|
286 |
-
{% endfor %}
|
287 |
</div>
|
288 |
</div>
|
289 |
</div>
|
@@ -343,7 +339,7 @@
|
|
343 |
</div>
|
344 |
|
345 |
<script>
|
346 |
-
let
|
347 |
let conversationHistory = [];
|
348 |
let currentAudio = null;
|
349 |
let currentEventSource = null;
|
@@ -398,11 +394,11 @@
|
|
398 |
chatArea.scrollTop = chatArea.scrollHeight;
|
399 |
}
|
400 |
|
401 |
-
function loadChat(
|
402 |
-
fetch(`/api/load_chat/${
|
403 |
.then(response => response.json())
|
404 |
.then(data => {
|
405 |
-
|
406 |
conversationHistory = data.messages;
|
407 |
document.getElementById('chatArea').innerHTML = '';
|
408 |
conversationHistory.forEach((message, index) => {
|
@@ -452,7 +448,7 @@
|
|
452 |
'Content-Type': 'application/json'
|
453 |
},
|
454 |
body: JSON.stringify({
|
455 |
-
|
456 |
message_index: editingMessageIndex,
|
457 |
content: newContent,
|
458 |
is_user: isUserMessage
|
@@ -544,7 +540,7 @@
|
|
544 |
base_host: baseHost,
|
545 |
model: model,
|
546 |
messages: conversationHistory,
|
547 |
-
|
548 |
}),
|
549 |
signal: abortController.signal
|
550 |
});
|
@@ -645,7 +641,7 @@
|
|
645 |
});
|
646 |
|
647 |
document.getElementById('newChatBtn').addEventListener('click', () => {
|
648 |
-
|
649 |
conversationHistory = [];
|
650 |
document.getElementById('chatArea').innerHTML = '';
|
651 |
// Restore selected models
|
@@ -693,9 +689,9 @@
|
|
693 |
});
|
694 |
|
695 |
document.getElementById('chatsList').addEventListener('click', (e) => {
|
696 |
-
const
|
697 |
-
if (
|
698 |
-
loadChat(
|
699 |
}
|
700 |
});
|
701 |
|
|
|
279 |
<div class="flex-grow overflow-y-auto px-4 sidebar-content">
|
280 |
<h3 class="text-sm font-semibold text-gray-400 mb-2">Saved Chats</h3>
|
281 |
<div id="chatsList" class="space-y-2">
|
282 |
+
<!-- Chat files will be inserted here -->
|
|
|
|
|
|
|
|
|
283 |
</div>
|
284 |
</div>
|
285 |
</div>
|
|
|
339 |
</div>
|
340 |
|
341 |
<script>
|
342 |
+
let currentSessionId = '{{ session_id }}';
|
343 |
let conversationHistory = [];
|
344 |
let currentAudio = null;
|
345 |
let currentEventSource = null;
|
|
|
394 |
chatArea.scrollTop = chatArea.scrollHeight;
|
395 |
}
|
396 |
|
397 |
+
function loadChat(sessionId) {
|
398 |
+
fetch(`/api/load_chat/${sessionId}`)
|
399 |
.then(response => response.json())
|
400 |
.then(data => {
|
401 |
+
currentSessionId = sessionId;
|
402 |
conversationHistory = data.messages;
|
403 |
document.getElementById('chatArea').innerHTML = '';
|
404 |
conversationHistory.forEach((message, index) => {
|
|
|
448 |
'Content-Type': 'application/json'
|
449 |
},
|
450 |
body: JSON.stringify({
|
451 |
+
session_id: currentSessionId,
|
452 |
message_index: editingMessageIndex,
|
453 |
content: newContent,
|
454 |
is_user: isUserMessage
|
|
|
540 |
base_host: baseHost,
|
541 |
model: model,
|
542 |
messages: conversationHistory,
|
543 |
+
session_id: currentSessionId
|
544 |
}),
|
545 |
signal: abortController.signal
|
546 |
});
|
|
|
641 |
});
|
642 |
|
643 |
document.getElementById('newChatBtn').addEventListener('click', () => {
|
644 |
+
currentSessionId = '{{ session_id }}';
|
645 |
conversationHistory = [];
|
646 |
document.getElementById('chatArea').innerHTML = '';
|
647 |
// Restore selected models
|
|
|
689 |
});
|
690 |
|
691 |
document.getElementById('chatsList').addEventListener('click', (e) => {
|
692 |
+
const sessionId = e.target.dataset.session;
|
693 |
+
if (sessionId) {
|
694 |
+
loadChat(sessionId);
|
695 |
}
|
696 |
});
|
697 |
|