Compare commits

...

5 Commits

Author SHA1 Message Date
mike
2e3f811f25 chore: update 3 file(s) 2025-12-28 03:21:59 +01:00
mike
5d6ccd0087 refactor: remove welcome message and prevent chat repopulation on model switch
Co-authored-by: aider (openai//models/qwen2.5-coder-32b-instruct-q4_k_m.gguf) <aider@aider.chat>
2025-12-28 03:19:34 +01:00
mike
13a0209e05 feat: add chat reset feature with welcome message
Co-authored-by: aider (openai//models/Qwen/Qwen2.5-Coder-32B-Instruct-GGUF/qwen2.5-coder-32b-instruct-q4_k_m.gguf) <aider@aider.chat>
2025-12-28 03:11:40 +01:00
mike
4d5467753b fix: restore all messages from chat history on page load
Co-authored-by: aider (openai//models/Qwen/Qwen2.5-Coder-32B-Instruct-GGUF/qwen2.5-coder-32b-instruct-q4_k_m.gguf) <aider@aider.chat>
2025-12-28 03:00:31 +01:00
mike
db0811e8a7 feat: store chat history in localStorage to preserve conversation on refresh
Co-authored-by: aider (openai//models/Qwen/Qwen2.5-Coder-32B-Instruct-GGUF/qwen2.5-coder-32b-instruct-q4_k_m.gguf) <aider@aider.chat>
2025-12-28 02:55:15 +01:00
4 changed files with 39 additions and 6 deletions

View File

@@ -1 +1 @@
model: /models/Qwen/Qwen2.5-Coder-32B-Instruct-GGUF/qwen2.5-coder-32b-instruct-q4_k_m.gguf
model: /models/qwen2.5-coder-32b-instruct-q4_k_m.gguf

View File

@@ -1,4 +1,4 @@
- name: /models/Qwen/Qwen2.5-Coder-32B-Instruct-GGUF/qwen2.5-coder-32b-instruct-q4_k_m.gguf
- name: /models/qwen2.5-coder-32b-instruct-q4_k_m.gguf
extra_params:
num_ctx: 16384
num_threads: 8

View File

@@ -27,7 +27,15 @@ let currentModel = null
let availableModels = []
let currentStreamController = null
let isStreaming = false
let chatHistory = [] // Stores conversation history
let chatHistory = JSON.parse(localStorage.getItem('chatHistory')) || [] // Stores conversation history
// Ensure chatHistory is an array of objects with the correct structure
chatHistory = chatHistory.map(message => ({
role : message.role || 'user',
content : message.content || '',
markdown : message.markdown || false,
messageId: message.messageId || `msg-${ Date.now() }`
}))
// Get current API URL based on selected backend
function getApiUrl() {
@@ -99,6 +107,8 @@ function trimChatHistory() {
if (chatHistory.length > MAX_CHAT_HISTORY) {
chatHistory = chatHistory.slice(-MAX_CHAT_HISTORY)
console.log(`Chat history trimmed to ${ MAX_CHAT_HISTORY } messages`)
// Save chat history to localStorage
localStorage.setItem('chatHistory', JSON.stringify(chatHistory))
}
}
@@ -207,6 +217,9 @@ function addMessage(role, content, markdown = false, messageId = null) {
// Trim history if it gets too long
trimChatHistory()
// Save chat history to localStorage
localStorage.setItem('chatHistory', JSON.stringify(chatHistory))
return contentDiv
}
@@ -598,8 +611,24 @@ window.onload = () => {
userInput.focus()
fetchModels()
// Add welcome message (this will be the first entry in chatHistory)
const welcomeMessage = `# Welcome to LM Studio Chat! ?
// Load chat history from localStorage
if (chatHistory.length === 0) {
// Add event listener for reset button
document.getElementById('resetBtn').addEventListener('click', resetChat)
}
}
// Reset chat history
function resetChat() {
// Clear chat history
chatHistory = []
// Clear chat log
chatLog.innerHTML = ''
// Add welcome message
const welcomeMessage = `# Welcome to LM Studio Chat!
I now support **full conversation history**, **real-time streaming responses** and **dark, readable text formatting**.
@@ -619,4 +648,7 @@ I now support **full conversation history**, **real-time streaming responses** a
> *Tip: You can toggle streaming and markdown using the checkboxes below.*`
addMessage('assistant', welcomeMessage, true)
// Save chat history to localStorage
localStorage.setItem('chatHistory', JSON.stringify(chatHistory))
}

View File

@@ -54,6 +54,7 @@
<div id="modelInfo">Model: <span id="modelName">unknown</span></div>
</div>
<button id="sendBtn">Send</button>
<button id="resetBtn">Reset Chat</button>
</div>
</div>
</div>