diff --git a/index.html b/index.html index f09084a..bab1497 100644 --- a/index.html +++ b/index.html @@ -468,6 +468,7 @@ let currentModel = null let availableModels = [] let currentStreamController = null let isStreaming = false +let chatHistory = [] // Initialize chat history array // Get current API URL based on selected backend function getApiUrl() { @@ -626,6 +627,9 @@ function addMessage(role, content, markdown = false, messageId = null) { chatLog.appendChild(messageDiv) chatLog.scrollTop = chatLog.scrollHeight + // Add message to chat history + chatHistory.push({ role, content, markdown, messageId }); + return contentDiv } @@ -1010,6 +1014,9 @@ window.onload = () => { userInput.focus() fetchModels() + // Load chat history + loadChatHistory(); + // Add welcome message setTimeout(() => { const welcomeMessage = `# Welcome to LM Studio Chat! 🚀 @@ -1035,3 +1042,8 @@ I now support **real-time streaming responses** and **dark, readable text format +function loadChatHistory() { + chatHistory.forEach(message => { + addMessage(message.role, message.content, message.markdown, message.messageId); + }); +}