@langfuse/core 4.5.1 → 4.6.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/LICENSE CHANGED
@@ -1,5 +1,8 @@
1
- Copyright (c) 2023 Finto Technologies GmbH
1
+ MIT License
2
2
 
3
+ This repository is licensed under the MIT License. Portions of this codebase are derived from posthog/posthog-js-lite by PostHog, which is also licensed under the MIT License.
4
+
5
+ Copyright (c) 2023-2026 Langfuse GmbH
3
6
  Copyright (c) 2022 PostHog (part of Hiberly Inc)
4
7
 
5
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
package/dist/index.cjs CHANGED
@@ -52,6 +52,7 @@ __export(index_exports, {
52
52
  ObservationType: () => ObservationType,
53
53
  PricingTierOperator: () => PricingTierOperator,
54
54
  PromptType: () => PromptType,
55
+ ScoreConfigDataType: () => ScoreConfigDataType,
55
56
  ScoreDataType: () => ScoreDataType,
56
57
  ScoreSource: () => ScoreSource,
57
58
  ServiceUnavailableError: () => ServiceUnavailableError,
@@ -299,6 +300,23 @@ var Logger = class {
299
300
  getLevel() {
300
301
  return this.config.level;
301
302
  }
303
+ /**
304
+ * Checks if a given log level is enabled.
305
+ * Use this to guard expensive operations (like JSON.stringify) before debug logging.
306
+ *
307
+ * @param level - The log level to check
308
+ * @returns True if the level is enabled, false otherwise
309
+ *
310
+ * @example
311
+ * ```typescript
312
+ * if (logger.isLevelEnabled(LogLevel.DEBUG)) {
313
+ * logger.debug('Expensive data:', JSON.stringify(largeObject));
314
+ * }
315
+ * ```
316
+ */
317
+ isLevelEnabled(level) {
318
+ return this.shouldLog(level);
319
+ }
302
320
  };
303
321
  var _a;
304
322
  var _LoggerSingleton = class _LoggerSingleton {
@@ -353,7 +371,7 @@ var resetGlobalLogger = () => {
353
371
  // package.json
354
372
  var package_default = {
355
373
  name: "@langfuse/core",
356
- version: "4.5.0",
374
+ version: "4.5.1",
357
375
  description: "Core functions and utilities for Langfuse packages",
358
376
  type: "module",
359
377
  sideEffects: false,
@@ -510,6 +528,7 @@ __export(commons_exports, {
510
528
  NotFoundError: () => NotFoundError,
511
529
  ObservationLevel: () => ObservationLevel,
512
530
  PricingTierOperator: () => PricingTierOperator,
531
+ ScoreConfigDataType: () => ScoreConfigDataType,
513
532
  ScoreDataType: () => ScoreDataType,
514
533
  ScoreSource: () => ScoreSource,
515
534
  UnauthorizedError: () => UnauthorizedError
@@ -564,11 +583,19 @@ var ScoreSource = {
564
583
  Eval: "EVAL"
565
584
  };
566
585
 
586
+ // src/api/api/resources/commons/types/ScoreConfigDataType.ts
587
+ var ScoreConfigDataType = {
588
+ Numeric: "NUMERIC",
589
+ Boolean: "BOOLEAN",
590
+ Categorical: "CATEGORICAL"
591
+ };
592
+
567
593
  // src/api/api/resources/commons/types/ScoreDataType.ts
568
594
  var ScoreDataType = {
569
595
  Numeric: "NUMERIC",
570
596
  Boolean: "BOOLEAN",
571
- Categorical: "CATEGORICAL"
597
+ Categorical: "CATEGORICAL",
598
+ Correction: "CORRECTION"
572
599
  };
573
600
 
574
601
  // src/api/core/json.ts
@@ -3650,7 +3677,8 @@ var DatasetItems = class {
3650
3677
  }
3651
3678
  }
3652
3679
  /**
3653
- * Get dataset items
3680
+ * Get dataset items. Optionally specify a version to get the items as they existed at that point in time.
3681
+ * Note: If version parameter is provided, datasetName must also be provided.
3654
3682
  *
3655
3683
  * @param {LangfuseAPI.GetDatasetItemsRequest} request
3656
3684
  * @param {DatasetItems.RequestOptions} requestOptions - Request-specific configuration.
@@ -3671,7 +3699,14 @@ var DatasetItems = class {
3671
3699
  }
3672
3700
  async __list(request = {}, requestOptions) {
3673
3701
  var _a2, _b, _c, _d, _e, _f, _g, _h;
3674
- const { datasetName, sourceTraceId, sourceObservationId, page, limit } = request;
3702
+ const {
3703
+ datasetName,
3704
+ sourceTraceId,
3705
+ sourceObservationId,
3706
+ version,
3707
+ page,
3708
+ limit
3709
+ } = request;
3675
3710
  const _queryParams = {};
3676
3711
  if (datasetName != null) {
3677
3712
  _queryParams["datasetName"] = datasetName;
@@ -3682,6 +3717,9 @@ var DatasetItems = class {
3682
3717
  if (sourceObservationId != null) {
3683
3718
  _queryParams["sourceObservationId"] = sourceObservationId;
3684
3719
  }
3720
+ if (version != null) {
3721
+ _queryParams["version"] = version;
3722
+ }
3685
3723
  if (page != null) {
3686
3724
  _queryParams["page"] = page.toString();
3687
3725
  }
@@ -3909,7 +3947,8 @@ var DatasetRunItems = class {
3909
3947
  * metadata: undefined,
3910
3948
  * datasetItemId: "datasetItemId",
3911
3949
  * observationId: undefined,
3912
- * traceId: undefined
3950
+ * traceId: undefined,
3951
+ * datasetVersion: undefined
3913
3952
  * })
3914
3953
  */
3915
3954
  create(request, requestOptions) {
@@ -5928,6 +5967,8 @@ var Metrics = class {
5928
5967
  /**
5929
5968
  * Get metrics from the Langfuse project using a query object.
5930
5969
  *
5970
+ * Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance.
5971
+ *
5931
5972
  * For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
5932
5973
  *
5933
5974
  * @param {LangfuseAPI.GetMetricsRequest} request
@@ -6514,7 +6555,7 @@ var ObservationsV2 = class {
6514
6555
  * - `basic` - name, level, statusMessage, version, environment, bookmarked, public, userId, sessionId
6515
6556
  * - `time` - completionStartTime, createdAt, updatedAt
6516
6557
  * - `io` - input, output
6517
- * - `metadata` - metadata
6558
+ * - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
6518
6559
  * - `model` - providedModelName, internalModelId, modelParameters
6519
6560
  * - `usage` - usageDetails, costDetails, totalCost
6520
6561
  * - `prompt` - promptId, promptName, promptVersion
@@ -6547,6 +6588,7 @@ var ObservationsV2 = class {
6547
6588
  var _a2, _b, _c, _d, _e, _f, _g, _h;
6548
6589
  const {
6549
6590
  fields,
6591
+ expandMetadata,
6550
6592
  limit,
6551
6593
  cursor,
6552
6594
  parseIoAsJson,
@@ -6566,6 +6608,9 @@ var ObservationsV2 = class {
6566
6608
  if (fields != null) {
6567
6609
  _queryParams["fields"] = fields;
6568
6610
  }
6611
+ if (expandMetadata != null) {
6612
+ _queryParams["expandMetadata"] = expandMetadata;
6613
+ }
6569
6614
  if (limit != null) {
6570
6615
  _queryParams["limit"] = limit.toString();
6571
6616
  }
@@ -6815,7 +6860,9 @@ var Observations = class {
6815
6860
  }
6816
6861
  }
6817
6862
  /**
6818
- * Get a list of observations
6863
+ * Get a list of observations.
6864
+ *
6865
+ * Consider using the [v2 observations endpoint](/api-reference#tag/observationsv2/GET/api/public/v2/observations) for cursor-based pagination and field selection.
6819
6866
  *
6820
6867
  * @param {LangfuseAPI.GetObservationsRequest} request
6821
6868
  * @param {Observations.RequestOptions} requestOptions - Request-specific configuration.
@@ -8260,7 +8307,7 @@ var Projects = class {
8260
8307
  * await client.projects.update("projectId", {
8261
8308
  * name: "name",
8262
8309
  * metadata: undefined,
8263
- * retention: 1
8310
+ * retention: undefined
8264
8311
  * })
8265
8312
  */
8266
8313
  update(projectId, request, requestOptions) {
@@ -10667,7 +10714,8 @@ var ScoreV2 = class {
10667
10714
  traceId,
10668
10715
  queueId,
10669
10716
  dataType,
10670
- traceTags
10717
+ traceTags,
10718
+ fields
10671
10719
  } = request;
10672
10720
  const _queryParams = {};
10673
10721
  if (page != null) {
@@ -10732,6 +10780,9 @@ var ScoreV2 = class {
10732
10780
  _queryParams["traceTags"] = traceTags;
10733
10781
  }
10734
10782
  }
10783
+ if (fields != null) {
10784
+ _queryParams["fields"] = fields;
10785
+ }
10735
10786
  let _headers = mergeHeaders(
10736
10787
  (_a2 = this._options) == null ? void 0 : _a2.headers,
10737
10788
  mergeOnlyDefinedHeaders({
@@ -12629,6 +12680,7 @@ function getSpanKeyFromBaggageKey(baggageKey) {
12629
12680
  ObservationType,
12630
12681
  PricingTierOperator,
12631
12682
  PromptType,
12683
+ ScoreConfigDataType,
12632
12684
  ScoreDataType,
12633
12685
  ScoreSource,
12634
12686
  ServiceUnavailableError,