Merge caitlin/CRM_ENVR: AI chat ref+health, tips panel, cyberpunk theme, app-shell/bg improvements

This commit is contained in:
JCBSComputer
2026-07-01 09:36:04 +02:00
56 changed files with 2693 additions and 504 deletions
+30
View File
@@ -202,6 +202,7 @@ Provide concise, actionable sales advice. When asked about a specific job catego
{ role: "user", content: userMessage },
],
stream: false,
keep_alive: "30m",
options: { temperature: 0.7, num_predict: 1024 },
}),
})
@@ -576,11 +577,40 @@ async function processRequest(req, res, body, startTime) {
}
})
// ── Warm up model on startup ────────────────────────────────────
// Pre-loads the model into Ollama's memory so the first user
// request doesn't pay the cold-start penalty.
async function warmModel() {
console.log(`Warming up model ${MODEL}...`)
try {
const res = await fetch(`${OLLAMA_URL}/api/generate`, {
method: "POST",
headers: { "Content-Type": "application/json" },
signal: AbortSignal.timeout(300000),
body: JSON.stringify({
model: MODEL,
prompt: "Hello",
keep_alive: "30m",
options: { num_predict: 1 },
}),
})
if (res.ok) {
console.log(`Model ${MODEL} loaded and kept alive for 30 minutes`)
} else {
console.warn(`Model warm-up returned ${res.status}`)
}
} catch (err) {
console.warn(`Model warm-up failed (will load on first request): ${err.message}`)
}
}
// ── Start ───────────────────────────────────────────────────────
server.listen(PORT, HOST, () => {
console.log(`CRM AI server listening on http://${HOST}:${PORT}`)
console.log(` Model: ${MODEL}`)
console.log(` Ollama: ${OLLAMA_URL}`)
// Kick off warm-up in background (don't block server start)
warmModel()
})
initPg()