Compare commits
5 Commits
3c7c4d4233
...
2e3f811f25
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e3f811f25 | ||
|
|
5d6ccd0087 | ||
|
|
13a0209e05 | ||
|
|
4d5467753b | ||
|
|
db0811e8a7 |
@@ -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
|
||||||
@@ -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:
|
extra_params:
|
||||||
num_ctx: 16384
|
num_ctx: 16384
|
||||||
num_threads: 8
|
num_threads: 8
|
||||||
38
chatv2.js
38
chatv2.js
@@ -27,7 +27,15 @@ let currentModel = null
|
|||||||
let availableModels = []
|
let availableModels = []
|
||||||
let currentStreamController = null
|
let currentStreamController = null
|
||||||
let isStreaming = false
|
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
|
// Get current API URL based on selected backend
|
||||||
function getApiUrl() {
|
function getApiUrl() {
|
||||||
@@ -99,6 +107,8 @@ function trimChatHistory() {
|
|||||||
if (chatHistory.length > MAX_CHAT_HISTORY) {
|
if (chatHistory.length > MAX_CHAT_HISTORY) {
|
||||||
chatHistory = chatHistory.slice(-MAX_CHAT_HISTORY)
|
chatHistory = chatHistory.slice(-MAX_CHAT_HISTORY)
|
||||||
console.log(`Chat history trimmed to ${ MAX_CHAT_HISTORY } messages`)
|
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
|
// Trim history if it gets too long
|
||||||
trimChatHistory()
|
trimChatHistory()
|
||||||
|
|
||||||
|
// Save chat history to localStorage
|
||||||
|
localStorage.setItem('chatHistory', JSON.stringify(chatHistory))
|
||||||
|
|
||||||
return contentDiv
|
return contentDiv
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,8 +611,24 @@ window.onload = () => {
|
|||||||
userInput.focus()
|
userInput.focus()
|
||||||
fetchModels()
|
fetchModels()
|
||||||
|
|
||||||
// Add welcome message (this will be the first entry in chatHistory)
|
// Load chat history from localStorage
|
||||||
const welcomeMessage = `# Welcome to LM Studio Chat! ?
|
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**.
|
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.*`
|
> *Tip: You can toggle streaming and markdown using the checkboxes below.*`
|
||||||
|
|
||||||
addMessage('assistant', welcomeMessage, true)
|
addMessage('assistant', welcomeMessage, true)
|
||||||
|
|
||||||
|
// Save chat history to localStorage
|
||||||
|
localStorage.setItem('chatHistory', JSON.stringify(chatHistory))
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,7 @@
|
|||||||
<div id="modelInfo">Model: <span id="modelName">unknown</span></div>
|
<div id="modelInfo">Model: <span id="modelName">unknown</span></div>
|
||||||
</div>
|
</div>
|
||||||
<button id="sendBtn">Send</button>
|
<button id="sendBtn">Send</button>
|
||||||
|
<button id="resetBtn">Reset Chat</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user