feat: introduce chat sessions and manage chat history
Co-authored-by: aider (openai//models/qwen2.5-coder-32b-instruct-q4_k_m.gguf) <aider@aider.chat>
This commit is contained in:
12
index.html
12
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
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
function loadChatHistory() {
|
||||
chatHistory.forEach(message => {
|
||||
addMessage(message.role, message.content, message.markdown, message.messageId);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user