This commit is contained in:
lila 2026-07-06 15:35:22 +02:00
parent e89e3b7a70
commit 8e8484f875
3 changed files with 281 additions and 145 deletions

View file

@ -18,13 +18,10 @@ export async function checkLlmServer(
// llama.cpp returns a 503 status if the server is up but the model weights are still loading
if (response.status === 503) {
console.error(
"\n ⏳ Local AI engine is starting up, but the model is still loading into memory.",
throw new Error(
"Local AI engine is starting up, but the model is still loading into memory. " +
"Please wait a minute for the weights to load, then run the pipeline again.",
);
console.error(
"👉 Please wait a minute for the weights to load, then run the pipeline again.\n",
);
process.exit(1);
}
// Parse the JSON health response (expected: { status: "ok" })
@ -36,16 +33,17 @@ export async function checkLlmServer(
}
// Catch-all for unexpected active server responses
console.error(
`\n ❌ Unknown response from local AI engine health check (Status: ${response.status}).`,
throw new Error(
`Unknown response from local AI engine health check (Status: ${response.status}).`,
);
process.exit(1);
} catch (_error: unknown) {
console.error("\n ❌ Could not connect to the local AI engine.");
console.error(`🔗 Attempted endpoint: ${url}`);
console.error(
"👉 Make sure your './llama-server' command is actively running in another terminal tab!\n",
} catch (error: unknown) {
if (error instanceof Error && error.message.includes("Local AI engine")) {
throw error; // Re-throw our own errors
}
throw new Error(
`Could not connect to the local AI engine at ${url}. ` +
"Make sure your './llama-server' command is actively running in another terminal tab.",
{ cause: error },
);
process.exit(1);
}
}