wip
This commit is contained in:
parent
cc89f0c75c
commit
afd28d934e
26 changed files with 2103 additions and 427 deletions
43
data-pipeline/utils/check-llm-server.ts
Normal file
43
data-pipeline/utils/check-llm-server.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* Pings the local llama.cpp server to ensure it's up, running, and has a model loaded.
|
||||
* If the server is offline or still loading, it terminates the pipeline gracefully.
|
||||
*/
|
||||
export async function checkLlmServer(
|
||||
url = "http://127.0.0.1:8080/health",
|
||||
): Promise<void> {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
|
||||
// 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.",
|
||||
);
|
||||
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" })
|
||||
const data = (await response.json()) as { status?: string };
|
||||
|
||||
if (response.ok && data.status === "ok") {
|
||||
console.log("🟢 Local AI engine is connected and ready for inference!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Catch-all for unexpected active server responses
|
||||
console.error(
|
||||
`\n ❌ 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",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue