@acarmisc/backstage-plugin-litellm-backend 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.d.ts +39 -0
- package/dist/client.js +16 -15
- package/dist/index.cjs.js +325 -69
- package/dist/index.cjs.js.map +4 -4
- package/dist/langfuse.d.ts +32 -0
- package/dist/langfuse.js +18 -0
- package/dist/langfuseClient.d.ts +23 -0
- package/dist/langfuseClient.js +171 -0
- package/dist/plugin.js +1 -0
- package/dist/router.js +3 -0
- package/dist/routes/bridge.js +24 -0
- package/dist/routes/context.d.ts +2 -0
- package/dist/routes/insights.js +37 -0
- package/dist/services/keyService.js +27 -1
- package/dist/services/mcpAccess.d.ts +20 -0
- package/dist/services/mcpAccess.js +28 -0
- package/dist/types.cjs.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
package/config.d.ts
CHANGED
|
@@ -234,6 +234,45 @@ export interface Config {
|
|
|
234
234
|
metadata?: { [key: string]: string };
|
|
235
235
|
};
|
|
236
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Langfuse answer-quality scores for the Insights tab ("Quality scores"
|
|
239
|
+
* card, GET /insights/quality). Generic Metrics API v2 integration: any
|
|
240
|
+
* Langfuse host works, and a disabled, unconfigured, or v3 server
|
|
241
|
+
* degrades to `{configured:false}` instead of erroring.
|
|
242
|
+
*/
|
|
243
|
+
langfuse?: {
|
|
244
|
+
/**
|
|
245
|
+
* When true the /insights/quality route queries Langfuse.
|
|
246
|
+
* @default false
|
|
247
|
+
*/
|
|
248
|
+
enabled?: boolean;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Langfuse host, e.g. https://langfuse.example.com.
|
|
252
|
+
* @visibility backend
|
|
253
|
+
*/
|
|
254
|
+
baseUrl?: string;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Langfuse public key (Metrics API Basic-auth username).
|
|
258
|
+
* @visibility backend
|
|
259
|
+
*/
|
|
260
|
+
publicKey?: string;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Langfuse secret key (Metrics API Basic-auth password).
|
|
264
|
+
* @visibility secret
|
|
265
|
+
*/
|
|
266
|
+
secretKey?: string;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* The Langfuse observation field holding the LiteLLM user id.
|
|
270
|
+
* Deployments whose agents tag traces differently change this one key.
|
|
271
|
+
* @default "userId"
|
|
272
|
+
*/
|
|
273
|
+
userIdField?: string;
|
|
274
|
+
};
|
|
275
|
+
|
|
237
276
|
/**
|
|
238
277
|
* Caching configuration for backend data fetches.
|
|
239
278
|
*/
|
package/dist/client.js
CHANGED
|
@@ -724,22 +724,23 @@ class LiteLLMClient {
|
|
|
724
724
|
return this.normalizeSpendLogs(raw, page, pageSize);
|
|
725
725
|
}
|
|
726
726
|
normalizeSpendLogs(raw, page, pageSize) {
|
|
727
|
-
const rows =
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
727
|
+
const rows = [];
|
|
728
|
+
if (Array.isArray(raw))
|
|
729
|
+
rows.push(...raw);
|
|
730
|
+
else if (Array.isArray(raw?.data))
|
|
731
|
+
rows.push(...raw.data);
|
|
732
|
+
else if (Array.isArray(raw?.results))
|
|
733
|
+
rows.push(...raw.results);
|
|
734
|
+
else if (Array.isArray(raw?.logs))
|
|
735
|
+
rows.push(...raw.logs);
|
|
736
736
|
const toNum = (v, fallback = 0) => {
|
|
737
|
-
|
|
738
|
-
? v
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
737
|
+
if (typeof v === 'number')
|
|
738
|
+
return Number.isFinite(v) ? v : fallback;
|
|
739
|
+
if (typeof v === 'string' && v.trim() !== '') {
|
|
740
|
+
const n = Number(v);
|
|
741
|
+
return Number.isFinite(n) ? n : fallback;
|
|
742
|
+
}
|
|
743
|
+
return fallback;
|
|
743
744
|
};
|
|
744
745
|
const data = rows.map((r) => {
|
|
745
746
|
const promptTokens = toNum(r?.prompt_tokens ?? r?.promptTokens ?? r?.input_tokens);
|