A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
fix: target llama.cpp stats to displayed model (#7150)
Thomasd46f69654973
diff --git a/packages/integrations/src/llama-cpp/llamacpp-integration.ts b/packages/integrations/src/llama-cpp/llamacpp-integration.tsindex 9640c78ed..fcc3984e9 100644--- a/packages/integrations/src/llama-cpp/llamacpp-integration.ts+++ b/packages/integrations/src/llama-cpp/llamacpp-integration.ts@@ -46,12 +46,9 @@ export class LlamacppIntegration extends Integration {}public async getStatsAsync(): Promise<LlamacppStats> {- const [healthResponse, modelsResponse, metricsResponse, slotsResponse] = await Promise.all([+ const [healthResponse, modelsResponse] = await Promise.all([fetchWithTrustedCertificatesAsync(this.url("/health"), { timeout: LLMACPP_REQUEST_TIMEOUT_MS }),fetchWithTrustedCertificatesAsync(this.url("/v1/models"), { timeout: LLMACPP_REQUEST_TIMEOUT_MS }),- fetchWithTrustedCertificatesAsync(this.url("/metrics"), { timeout: LLMACPP_REQUEST_TIMEOUT_MS }),- // /slots is not present on every build; a missing endpoint degrades to no context usage.- fetchWithTrustedCertificatesAsync(this.url("/slots"), { timeout: LLMACPP_REQUEST_TIMEOUT_MS }).catch(() => null),]);if (!healthResponse.ok) {@@ -61,14 +58,28 @@ export class LlamacppIntegration extends Integration {throw new ResponseError(modelsResponse);}+ const [health, models] = await Promise.all([+ parseLlamacppHealthAsync(healthResponse),+ parseLlamacppModelsAsync(modelsResponse),+ ]);+ const firstModelId = models.data[0]?.id;++ const [metricsResponse, slotsResponse] = await Promise.all([+ fetchWithTrustedCertificatesAsync(this.url("/metrics", { model: firstModelId }), {+ timeout: LLMACPP_REQUEST_TIMEOUT_MS,+ }),+ // /slots is not present on every build; a missing endpoint degrades to no context usage.+ fetchWithTrustedCertificatesAsync(this.url("/slots", { model: firstModelId }), {+ timeout: LLMACPP_REQUEST_TIMEOUT_MS,+ }).catch(() => null),+ ]);+// /metrics only exists when llama-server was started with --metrics; a non-OK// response (typically 501 Not Implemented) degrades to no rate counters instead// of dropping the health and model data that the other endpoints still provide.const metricsAvailable = metricsResponse.ok;- const [health, models, metrics, slots] = await Promise.all([- parseLlamacppHealthAsync(healthResponse),- parseLlamacppModelsAsync(modelsResponse),+ const [metrics, slots] = await Promise.all([metricsAvailable ? parseLlamacppMetricsAsync(metricsResponse) : Promise.resolve([]),slotsResponse?.ok ? parseLlamacppSlotsAsync(slotsResponse) : Promise.resolve(null),]);diff --git a/packages/integrations/src/llama-cpp/test/llamacpp-integration.spec.ts b/packages/integrations/src/llama-cpp/test/llamacpp-integration.spec.tsindex 966ed9083..88d981170 100644--- a/packages/integrations/src/llama-cpp/test/llamacpp-integration.spec.ts+++ b/packages/integrations/src/llama-cpp/test/llamacpp-integration.spec.ts@@ -342,7 +342,12 @@ describe("LlamacppIntegration getStatsAsync", () => {const requestedUrls = mockFetch.mock.calls.map((call) => String(call[0])).toSorted();expect(requestedUrls).toStrictEqual(- [`${TEST_URL}/health`, `${TEST_URL}/metrics`, `${TEST_URL}/slots`, `${TEST_URL}/v1/models`].toSorted(),+ [+ `${TEST_URL}/health`,+ `${TEST_URL}/metrics?model=%2Froot%2Fmodels%2Funsloth%2FQwen3.8-27B-UD-Q4_K_XL.gguf`,+ `${TEST_URL}/slots?model=%2Froot%2Fmodels%2Funsloth%2FQwen3.8-27B-UD-Q4_K_XL.gguf`,+ `${TEST_URL}/v1/models`,+ ].toSorted(),);});