chore: update 1 file(s)
This commit is contained in:
28
chatv2.js
28
chatv2.js
@@ -15,11 +15,29 @@ const BACKENDS = {
|
|||||||
name: 'Ollama (192.168.1.159:8081)'
|
name: 'Ollama (192.168.1.159:8081)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const IS_PRODUCTION = window.location.hostname === 'jarvis-lan.appmodel.nl'
|
const IS_PRODUCTION = window.location.hostname === 'jarvis-lan.appmodel.nl'
|
||||||
const API_KEY = 'not-needed'
|
const API_KEY = 'not-needed'
|
||||||
const MAX_CHAT_HISTORY = 50
|
const MAX_CHAT_HISTORY = 50
|
||||||
|
|
||||||
|
const welcomeMessage = `# Welcome to LM Studio Chat!
|
||||||
|
|
||||||
|
I now support **full conversation history**, **real-time streaming responses** and **dark, readable text formatting**.
|
||||||
|
|
||||||
|
## Features:
|
||||||
|
1. **Full Chat History** - Complete conversation context is now sent to the AI
|
||||||
|
2. **Smart History Management** - Automatically keeps the last ${ MAX_CHAT_HISTORY } messages
|
||||||
|
3. **Streaming Mode** (enabled by default) - Watch responses appear word-by-word
|
||||||
|
4. **Markdown Rendering** - Proper formatting for code, lists, tables, and more
|
||||||
|
5. **Readable Dark Text** - No more eye strain from light gray text
|
||||||
|
|
||||||
|
## Try it out:
|
||||||
|
- Ask follow-up questions that reference earlier messages
|
||||||
|
- Have a multi-turn conversation with full context
|
||||||
|
- Ask "what did I just ask?" to test history retention
|
||||||
|
- Watch the streaming response in real-time!
|
||||||
|
|
||||||
|
> *Tip: You can toggle streaming and markdown using the checkboxes below.*`
|
||||||
|
|
||||||
let currentBackend = 'plato'
|
let currentBackend = 'plato'
|
||||||
let currentModel = null
|
let currentModel = null
|
||||||
let availableModels = []
|
let availableModels = []
|
||||||
@@ -454,6 +472,7 @@ async function handleStreamingResponse(userMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleNonStreamingResponse(userMessage) {
|
async function handleNonStreamingResponse(userMessage) {
|
||||||
|
try {
|
||||||
const typingIndicator = showTypingIndicator()
|
const typingIndicator = showTypingIndicator()
|
||||||
|
|
||||||
if (!currentModel && availableModels.length > 0) {
|
if (!currentModel && availableModels.length > 0) {
|
||||||
@@ -492,13 +511,14 @@ async function handleNonStreamingResponse(userMessage) {
|
|||||||
addMessage('assistant', 'No response generated.', false)
|
addMessage('assistant', 'No response generated.', false)
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error:', error)
|
console.error('Error:', error)
|
||||||
removeTypingIndicator(typingIndicator)
|
removeTypingIndicator(typingIndicator)
|
||||||
addMessage('assistant', `Error: ${ error.message }`, false)
|
addMessage('assistant', `Error: ${ error.message }`, false)
|
||||||
} finally {
|
} finally {
|
||||||
sendBtn.disabled = false
|
sendBtn.disabled = false
|
||||||
userInput.focus()
|
userInput.focus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopStream() {
|
function stopStream() {
|
||||||
@@ -559,7 +579,7 @@ window.onload = () => {
|
|||||||
|
|
||||||
function resetChat() {
|
function resetChat() {
|
||||||
chatHistory = []
|
chatHistory = []
|
||||||
chatLog.innerHTML = ''
|
chatLog.innerHTML = welcomeMessage
|
||||||
|
|
||||||
localStorage.setItem('chatHistory', JSON.stringify(chatHistory))
|
localStorage.setItem('chatHistory', JSON.stringify(chatHistory))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user