Spaces:
Running
Running
i do not see a regenerate button. can you make it show a list of button (regenerate, edit) when hovering a assistant message and show only edit when hovering user message - Follow Up Deployment
Browse files- index.html +57 -2
index.html
CHANGED
|
@@ -507,14 +507,27 @@
|
|
| 507 |
<div class="flex-shrink-0 w-8 h-8 rounded-full bg-primary-500 text-white flex items-center justify-center">
|
| 508 |
<i class="fas fa-robot"></i>
|
| 509 |
</div>
|
| 510 |
-
<div class="max-w-[80%] bg-white dark:bg-gray-800 rounded-lg p-4 shadow-sm">
|
| 511 |
<div class="prose dark:prose-invert">${msg.content}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 512 |
</div>
|
| 513 |
`;
|
| 514 |
} else {
|
| 515 |
messageElement.innerHTML = `
|
| 516 |
-
<div class="max-w-[80%] bg-primary-500 text-white rounded-lg p-4 shadow-sm">
|
| 517 |
<div class="prose prose-white">${msg.content}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
</div>
|
| 519 |
`;
|
| 520 |
}
|
|
@@ -524,6 +537,7 @@
|
|
| 524 |
|
| 525 |
chatArea.appendChild(messagesContainer);
|
| 526 |
chatArea.scrollTop = chatArea.scrollHeight;
|
|
|
|
| 527 |
}
|
| 528 |
|
| 529 |
// Send message
|
|
@@ -974,8 +988,49 @@
|
|
| 974 |
// You can replace this with actual settings modal later
|
| 975 |
});
|
| 976 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 977 |
// Initialize the app
|
| 978 |
init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 979 |
</script>
|
| 980 |
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - �� <a href="https://enzostvs-deepsite.hf.space?remix=kokofixcomputers/nexuschat" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 981 |
</html>
|
|
|
|
| 507 |
<div class="flex-shrink-0 w-8 h-8 rounded-full bg-primary-500 text-white flex items-center justify-center">
|
| 508 |
<i class="fas fa-robot"></i>
|
| 509 |
</div>
|
| 510 |
+
<div class="max-w-[80%] bg-white dark:bg-gray-800 rounded-lg p-4 shadow-sm relative group">
|
| 511 |
<div class="prose dark:prose-invert">${msg.content}</div>
|
| 512 |
+
<div class="absolute right-2 top-2 opacity-0 group-hover:opacity-100 transition-opacity flex gap-1">
|
| 513 |
+
<button class="message-action bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 p-1 rounded text-gray-700 dark:text-gray-300" data-action="regenerate" title="Regenerate">
|
| 514 |
+
<i class="fas fa-sync-alt text-xs"></i>
|
| 515 |
+
</button>
|
| 516 |
+
<button class="message-action bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 p-1 rounded text-gray-700 dark:text-gray-300" data-action="edit" title="Edit">
|
| 517 |
+
<i class="fas fa-edit text-xs"></i>
|
| 518 |
+
</button>
|
| 519 |
+
</div>
|
| 520 |
</div>
|
| 521 |
`;
|
| 522 |
} else {
|
| 523 |
messageElement.innerHTML = `
|
| 524 |
+
<div class="max-w-[80%] bg-primary-500 text-white rounded-lg p-4 shadow-sm relative group">
|
| 525 |
<div class="prose prose-white">${msg.content}</div>
|
| 526 |
+
<div class="absolute right-2 top-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
| 527 |
+
<button class="message-action bg-primary-600 hover:bg-primary-700 p-1 rounded text-white" data-action="edit" title="Edit">
|
| 528 |
+
<i class="fas fa-edit text-xs"></i>
|
| 529 |
+
</button>
|
| 530 |
+
</div>
|
| 531 |
</div>
|
| 532 |
`;
|
| 533 |
}
|
|
|
|
| 537 |
|
| 538 |
chatArea.appendChild(messagesContainer);
|
| 539 |
chatArea.scrollTop = chatArea.scrollHeight;
|
| 540 |
+
updateRegenerateButton();
|
| 541 |
}
|
| 542 |
|
| 543 |
// Send message
|
|
|
|
| 988 |
// You can replace this with actual settings modal later
|
| 989 |
});
|
| 990 |
|
| 991 |
+
// Handle message actions
|
| 992 |
+
function handleMessageAction(action, messageIndex) {
|
| 993 |
+
if (!currentChatId) return;
|
| 994 |
+
|
| 995 |
+
const chat = chats.find(c => c.id === currentChatId);
|
| 996 |
+
if (!chat || !chat.messages[messageIndex]) return;
|
| 997 |
+
|
| 998 |
+
if (action === 'regenerate') {
|
| 999 |
+
// Only regenerate if this is the last assistant message
|
| 1000 |
+
if (messageIndex === chat.messages.length - 1 &&
|
| 1001 |
+
chat.messages[messageIndex].role === 'assistant') {
|
| 1002 |
+
chat.messages.splice(messageIndex, 1);
|
| 1003 |
+
renderMessages(chat.messages);
|
| 1004 |
+
|
| 1005 |
+
// Resend last user message
|
| 1006 |
+
const lastUserMessage = chat.messages[chat.messages.length - 1];
|
| 1007 |
+
if (lastUserMessage && lastUserMessage.role === 'user') {
|
| 1008 |
+
sendMessage(lastUserMessage.content);
|
| 1009 |
+
}
|
| 1010 |
+
}
|
| 1011 |
+
} else if (action === 'edit') {
|
| 1012 |
+
// TODO: Implement edit functionality
|
| 1013 |
+
alert('Edit functionality will be implemented here');
|
| 1014 |
+
}
|
| 1015 |
+
}
|
| 1016 |
+
|
| 1017 |
// Initialize the app
|
| 1018 |
init();
|
| 1019 |
+
|
| 1020 |
+
// Add delegated event listener for message actions
|
| 1021 |
+
document.addEventListener('click', (e) => {
|
| 1022 |
+
const actionBtn = e.target.closest('.message-action');
|
| 1023 |
+
if (actionBtn) {
|
| 1024 |
+
e.preventDefault();
|
| 1025 |
+
e.stopPropagation();
|
| 1026 |
+
|
| 1027 |
+
const messageElement = actionBtn.closest('.flex.gap-4');
|
| 1028 |
+
const messageIndex = Array.from(messageElement.parentNode.children).indexOf(messageElement);
|
| 1029 |
+
const action = actionBtn.dataset.action;
|
| 1030 |
+
|
| 1031 |
+
handleMessageAction(action, messageIndex);
|
| 1032 |
+
}
|
| 1033 |
+
});
|
| 1034 |
</script>
|
| 1035 |
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - �� <a href="https://enzostvs-deepsite.hf.space?remix=kokofixcomputers/nexuschat" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 1036 |
</html>
|