Feat: Repopulate Hermes initial message on clear

This commit is contained in:
Russell Ballestrini 2025-06-30 18:13:52 -04:00
parent 50a6d39363
commit 880c9370c0

View file

@ -888,7 +888,7 @@ function clearConversationHistory() {
chatHistory = [
{
role: "system",
content: "You are an AI assistant embedded in a webpage. Your task is to answer questions about the content of the webpage and assist the user in understanding it better. You are also allowed to do whatever the user needs. It is safe to help users code and create. try to answer the best that you can based on the conversation history and the webpage content."
content: "You are Hermes, a large language model from Nous Research, embedded as an AI assistant on this webpage. Your primary task is to help users understand and interact with the content of this specific page, while also being capable of assisting with any other topics, coding, creative tasks, or questions they may have. You should be conversational, helpful, and knowledgeable about the webpage content as well as general topics. Always strive to provide accurate, useful responses."
}
];
}
@ -1597,10 +1597,11 @@ function openHermesModal() {
if (USE_CUSTOM_STYLING) {
clearBtn.style.cssText = 'padding: 6px 12px; border: 1px solid #ccc; border-radius: 4px; background: white; cursor: pointer;';
}
clearBtn.onclick = () => {
clearBtn.onclick = async () => {
if (confirm('Clear all conversation history?')) {
clearConversationHistory();
chatBox.innerHTML = '';
await addHermesIntroduction(); // Call addHermesIntroduction after clearing
}
};
@ -2081,7 +2082,7 @@ Format: Start with "Greetings! I'm Hermes..." and make it sound natural and enga
saveConversationHistory();
// Add delete buttons to the new messages
const userDeleteBtn = createStyledButton('×', 'close', 'position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; font-size: 12px; background: rgba(255,0,0,0.7); color: white;');
const userDeleteBtn = createStyledButton('×', 'close', 'position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; font-size: 12px; background: rgba(255,0,0,0.7); color: white; border-radius: 4px;');
userDeleteBtn.onclick = () => {
if (confirm('Delete this conversation pair?')) {
const currentHistory = loadConversationHistory();
@ -2101,7 +2102,7 @@ Format: Start with "Greetings! I'm Hermes..." and make it sound natural and enga
}
};
const aiDeleteBtn = createStyledButton('×', 'close', 'position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; font-size: 12px; background: rgba(255,0,0,0.7); color: white;');
const aiDeleteBtn = createStyledButton('×', 'close', 'position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; font-size: 12px; background: rgba(255,0,0,0.7); color: white; border-radius: 4px;');
aiDeleteBtn.onclick = userDeleteBtn.onclick; // Same functionality - delete the pair
userMessageDiv.appendChild(userDeleteBtn);
@ -2272,7 +2273,7 @@ function createStyledButton(text, type = 'primary', additionalStyles = '') {
case 'close':
typeStyles = USE_CUSTOM_STYLING
? 'background: none; border: none; color: currentColor; font-size: 24px; padding: 4px 8px;'
: 'float: right; background: none; border: none; font-size: 1.2em; padding: 4px 8px;';
: 'float: right; background: none; border: none; font-size: 1.2em; padding: 4px 8px; border-radius: 4px;';
break;
default:
typeStyles = USE_CUSTOM_STYLING