@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 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 = Array.isArray(raw)
728
- ? raw
729
- : Array.isArray(raw?.data)
730
- ? raw.data
731
- : Array.isArray(raw?.results)
732
- ? raw.results
733
- : Array.isArray(raw?.logs)
734
- ? raw.logs
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
- const n = typeof v === 'number'
738
- ? v
739
- : typeof v === 'string' && v.trim() !== ''
740
- ? Number(v)
741
- : NaN;
742
- return Number.isFinite(n) ? n : fallback;
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);