fix(hermes): ensure AI responses are saved to conversation history
- Manually add AI response to chatHistory after streaming completes - Fix missing Hermes responses when reopening modal - Update modal title to 'uncloseai.' with link to Nous Research Hermes - Add comprehensive debugging for conversation history save/load - Ensure proper history synchronization between modules
This commit is contained in:
parent
76e168cecf
commit
2048e25cd5
1 changed files with 12 additions and 8 deletions
20
src/ui.js
20
src/ui.js
|
|
@ -629,7 +629,7 @@ async function openHermesModalNew() {
|
|||
titleContainer.style.cssText = `flex: 1; display: flex; flex-direction: column; gap: 4px;`;
|
||||
|
||||
const title = document.createElement("h2");
|
||||
title.textContent = "🤖 Hermes AI";
|
||||
title.textContent = "🤖 uncloseai.";
|
||||
title.style.cssText = `
|
||||
margin: 0;
|
||||
font-size: ${isMobile ? '18px' : '20px'};
|
||||
|
|
@ -640,7 +640,7 @@ async function openHermesModalNew() {
|
|||
const pageTitle = document.title || window.location.hostname;
|
||||
subtitle.innerHTML = `
|
||||
<div style="font-size: 12px; opacity: 0.9; font-weight: normal; line-height: 1.3;">
|
||||
uncloseai. presents nous research's hermes large language model<br>
|
||||
uncloseai. presents nous research's <a href="https://nousresearch.com/hermes3/" target="_blank" style="color: rgba(255,255,255,0.9); text-decoration: underline;">hermes</a> large language model<br>
|
||||
<span style="opacity: 0.8;">You are discussing: ${pageTitle}</span>
|
||||
</div>
|
||||
`;
|
||||
|
|
@ -1106,13 +1106,16 @@ async function openHermesModalNew() {
|
|||
aiMsg.innerHTML = marked.parse(response);
|
||||
}
|
||||
|
||||
// Get the updated chat history from chat.js module
|
||||
const { getChatHistory } = await import('./chat.js');
|
||||
const updatedHistory = getChatHistory();
|
||||
// Add the AI response to chat history manually since sendMessage generator doesn't do it
|
||||
const { getChatHistory, updateChatHistory } = await import('./chat.js');
|
||||
const currentHistory = getChatHistory();
|
||||
currentHistory.push({ role: 'assistant', content: response });
|
||||
updateChatHistory(currentHistory);
|
||||
|
||||
// Save conversation history after successful response
|
||||
saveConversationHistory(updatedHistory);
|
||||
console.log("Conversation history saved:", updatedHistory.length, "messages");
|
||||
saveConversationHistory(currentHistory);
|
||||
console.log("Conversation history saved:", currentHistory.length, "messages");
|
||||
console.log("Saved history content:", currentHistory.map(msg => ({ role: msg.role, content: msg.content.substring(0, 50) + '...' })));
|
||||
|
||||
// Add TTS and delete buttons to AI message
|
||||
const messageActions = document.createElement("div");
|
||||
|
|
@ -1269,6 +1272,8 @@ async function openHermesModalNew() {
|
|||
const loadHistory = async () => {
|
||||
try {
|
||||
const history = loadConversationHistory();
|
||||
console.log("Raw history from localStorage:", history);
|
||||
console.log("History length:", history ? history.length : 0);
|
||||
if (history && history.length > 0) {
|
||||
// Set up page context for existing conversation
|
||||
const pageContent = extractWebpageContent();
|
||||
|
|
@ -1299,7 +1304,6 @@ You have complete knowledge of this page content and can reference any details,
|
|||
// Update the chat.js module's history
|
||||
updateChatHistory(newHistory);
|
||||
console.log("Chat history synced with loaded data:", newHistory.length, "messages");
|
||||
console.log("Current chatHistory contents:", chatHistory);
|
||||
console.log("History to display:", history);
|
||||
// Display previous conversation
|
||||
history.forEach((msg, index) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue