scai
Version:
> **AI-powered CLI for local code analysis, commit message suggestions, and natural-language queries.** 100% local, private, GDPR-friendly, made in Denmark/EU with ❤️.
31 lines (30 loc) • 886 B
JavaScript
import { spawn } from "child_process";
let modelProcess = null;
async function isModelRunning() {
try {
const res = await fetch("http://localhost:11434/health"); // whatever endpoint your model exposes
return res.ok;
}
catch {
return false;
}
}
export async function startModelProcess() {
if (await isModelRunning()) {
console.log("✅ Model already running");
return;
}
console.log("🚀 Starting model process...");
modelProcess = spawn("ollama", ["serve"], {
stdio: "inherit",
});
// Poll until the model is ready
for (let i = 0; i < 30; i++) {
if (await isModelRunning()) {
console.log("✅ Model is now running");
return;
}
await new Promise((res) => setTimeout(res, 1000));
}
throw new Error("❌ Model failed to start in time");
}