Compare commits
3 Commits
b681147565
...
5c2276ef1e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c2276ef1e | ||
|
|
cf810a3ba8 | ||
|
|
32abb9ffe7 |
16
index.html
16
index.html
@@ -44,6 +44,7 @@
|
|||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
|
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
|
||||||
font-size: 0.9em;
|
font-size: 0.9em;
|
||||||
|
user-select: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-content pre {
|
.markdown-content pre {
|
||||||
@@ -54,6 +55,7 @@
|
|||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
border: 1px solid #30363d;
|
border: 1px solid #30363d;
|
||||||
|
user-select: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown-content pre code {
|
.markdown-content pre code {
|
||||||
@@ -466,6 +468,7 @@ let currentModel = null
|
|||||||
let availableModels = []
|
let availableModels = []
|
||||||
let currentStreamController = null
|
let currentStreamController = null
|
||||||
let isStreaming = false
|
let isStreaming = false
|
||||||
|
let chatHistory = [] // Initialize chat history array
|
||||||
|
|
||||||
// Get current API URL based on selected backend
|
// Get current API URL based on selected backend
|
||||||
function getApiUrl() {
|
function getApiUrl() {
|
||||||
@@ -624,6 +627,9 @@ function addMessage(role, content, markdown = false, messageId = null) {
|
|||||||
chatLog.appendChild(messageDiv)
|
chatLog.appendChild(messageDiv)
|
||||||
chatLog.scrollTop = chatLog.scrollHeight
|
chatLog.scrollTop = chatLog.scrollHeight
|
||||||
|
|
||||||
|
// Add message to chat history
|
||||||
|
chatHistory.push({ role, content, markdown, messageId });
|
||||||
|
|
||||||
return contentDiv
|
return contentDiv
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -809,7 +815,7 @@ async function handleStreamingResponse(userMessage) {
|
|||||||
// Debounce DOM updates to reduce stutter
|
// Debounce DOM updates to reduce stutter
|
||||||
let updateScheduled = false
|
let updateScheduled = false
|
||||||
let lastUpdate = Date.now()
|
let lastUpdate = Date.now()
|
||||||
const MIN_UPDATE_INTERVAL = 50 // ms, update at most every 50ms
|
const MIN_UPDATE_INTERVAL = 100 // ms, update at most every 100ms
|
||||||
|
|
||||||
function scheduleUpdate() {
|
function scheduleUpdate() {
|
||||||
if (updateScheduled) return
|
if (updateScheduled) return
|
||||||
@@ -955,6 +961,11 @@ async function handleNonStreamingResponse(userMessage) {
|
|||||||
userInput.focus()
|
userInput.focus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function loadChatHistory() {
|
||||||
|
chatHistory.forEach(message => {
|
||||||
|
addMessage(message.role, message.content, message.markdown, message.messageId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Stop current stream
|
// Stop current stream
|
||||||
function stopStream() {
|
function stopStream() {
|
||||||
@@ -1008,6 +1019,9 @@ window.onload = () => {
|
|||||||
userInput.focus()
|
userInput.focus()
|
||||||
fetchModels()
|
fetchModels()
|
||||||
|
|
||||||
|
// Load chat history
|
||||||
|
loadChatHistory();
|
||||||
|
|
||||||
// Add welcome message
|
// Add welcome message
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const welcomeMessage = `# Welcome to LM Studio Chat! 🚀
|
const welcomeMessage = `# Welcome to LM Studio Chat! 🚀
|
||||||
|
|||||||
Reference in New Issue
Block a user