@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/dist/index.mjs CHANGED
@@ -199,6 +199,23 @@ var Logger = class {
199
199
  getLevel() {
200
200
  return this.config.level;
201
201
  }
202
+ /**
203
+ * Checks if a given log level is enabled.
204
+ * Use this to guard expensive operations (like JSON.stringify) before debug logging.
205
+ *
206
+ * @param level - The log level to check
207
+ * @returns True if the level is enabled, false otherwise
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * if (logger.isLevelEnabled(LogLevel.DEBUG)) {
212
+ * logger.debug('Expensive data:', JSON.stringify(largeObject));
213
+ * }
214
+ * ```
215
+ */
216
+ isLevelEnabled(level) {
217
+ return this.shouldLog(level);
218
+ }
202
219
  };
203
220
  var _a;
204
221
  var _LoggerSingleton = class _LoggerSingleton {
@@ -253,7 +270,7 @@ var resetGlobalLogger = () => {
253
270
  // package.json
254
271
  var package_default = {
255
272
  name: "@langfuse/core",
256
- version: "4.5.0",
273
+ version: "4.5.1",
257
274
  description: "Core functions and utilities for Langfuse packages",
258
275
  type: "module",
259
276
  sideEffects: false,
@@ -410,6 +427,7 @@ __export(commons_exports, {
410
427
  NotFoundError: () => NotFoundError,
411
428
  ObservationLevel: () => ObservationLevel,
412
429
  PricingTierOperator: () => PricingTierOperator,
430
+ ScoreConfigDataType: () => ScoreConfigDataType,
413
431
  ScoreDataType: () => ScoreDataType,
414
432
  ScoreSource: () => ScoreSource,
415
433
  UnauthorizedError: () => UnauthorizedError
@@ -464,11 +482,19 @@ var ScoreSource = {
464
482
  Eval: "EVAL"
465
483
  };
466
484
 
485
+ // src/api/api/resources/commons/types/ScoreConfigDataType.ts
486
+ var ScoreConfigDataType = {
487
+ Numeric: "NUMERIC",
488
+ Boolean: "BOOLEAN",
489
+ Categorical: "CATEGORICAL"
490
+ };
491
+
467
492
  // src/api/api/resources/commons/types/ScoreDataType.ts
468
493
  var ScoreDataType = {
469
494
  Numeric: "NUMERIC",
470
495
  Boolean: "BOOLEAN",
471
- Categorical: "CATEGORICAL"
496
+ Categorical: "CATEGORICAL",
497
+ Correction: "CORRECTION"
472
498
  };
473
499
 
474
500
  // src/api/core/json.ts
@@ -3550,7 +3576,8 @@ var DatasetItems = class {
3550
3576
  }
3551
3577
  }
3552
3578
  /**
3553
- * Get dataset items
3579
+ * Get dataset items. Optionally specify a version to get the items as they existed at that point in time.
3580
+ * Note: If version parameter is provided, datasetName must also be provided.
3554
3581
  *
3555
3582
  * @param {LangfuseAPI.GetDatasetItemsRequest} request
3556
3583
  * @param {DatasetItems.RequestOptions} requestOptions - Request-specific configuration.
@@ -3571,7 +3598,14 @@ var DatasetItems = class {
3571
3598
  }
3572
3599
  async __list(request = {}, requestOptions) {
3573
3600
  var _a2, _b, _c, _d, _e, _f, _g, _h;
3574
- const { datasetName, sourceTraceId, sourceObservationId, page, limit } = request;
3601
+ const {
3602
+ datasetName,
3603
+ sourceTraceId,
3604
+ sourceObservationId,
3605
+ version,
3606
+ page,
3607
+ limit
3608
+ } = request;
3575
3609
  const _queryParams = {};
3576
3610
  if (datasetName != null) {
3577
3611
  _queryParams["datasetName"] = datasetName;
@@ -3582,6 +3616,9 @@ var DatasetItems = class {
3582
3616
  if (sourceObservationId != null) {
3583
3617
  _queryParams["sourceObservationId"] = sourceObservationId;
3584
3618
  }
3619
+ if (version != null) {
3620
+ _queryParams["version"] = version;
3621
+ }
3585
3622
  if (page != null) {
3586
3623
  _queryParams["page"] = page.toString();
3587
3624
  }
@@ -3809,7 +3846,8 @@ var DatasetRunItems = class {
3809
3846
  * metadata: undefined,
3810
3847
  * datasetItemId: "datasetItemId",
3811
3848
  * observationId: undefined,
3812
- * traceId: undefined
3849
+ * traceId: undefined,
3850
+ * datasetVersion: undefined
3813
3851
  * })
3814
3852
  */
3815
3853
  create(request, requestOptions) {
@@ -5828,6 +5866,8 @@ var Metrics = class {
5828
5866
  /**
5829
5867
  * Get metrics from the Langfuse project using a query object.
5830
5868
  *
5869
+ * Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance.
5870
+ *
5831
5871
  * For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
5832
5872
  *
5833
5873
  * @param {LangfuseAPI.GetMetricsRequest} request
@@ -6414,7 +6454,7 @@ var ObservationsV2 = class {
6414
6454
  * - `basic` - name, level, statusMessage, version, environment, bookmarked, public, userId, sessionId
6415
6455
  * - `time` - completionStartTime, createdAt, updatedAt
6416
6456
  * - `io` - input, output
6417
- * - `metadata` - metadata
6457
+ * - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
6418
6458
  * - `model` - providedModelName, internalModelId, modelParameters
6419
6459
  * - `usage` - usageDetails, costDetails, totalCost
6420
6460
  * - `prompt` - promptId, promptName, promptVersion
@@ -6447,6 +6487,7 @@ var ObservationsV2 = class {
6447
6487
  var _a2, _b, _c, _d, _e, _f, _g, _h;
6448
6488
  const {
6449
6489
  fields,
6490
+ expandMetadata,
6450
6491
  limit,
6451
6492
  cursor,
6452
6493
  parseIoAsJson,
@@ -6466,6 +6507,9 @@ var ObservationsV2 = class {
6466
6507
  if (fields != null) {
6467
6508
  _queryParams["fields"] = fields;
6468
6509
  }
6510
+ if (expandMetadata != null) {
6511
+ _queryParams["expandMetadata"] = expandMetadata;
6512
+ }
6469
6513
  if (limit != null) {
6470
6514
  _queryParams["limit"] = limit.toString();
6471
6515
  }
@@ -6715,7 +6759,9 @@ var Observations = class {
6715
6759
  }
6716
6760
  }
6717
6761
  /**
6718
- * Get a list of observations
6762
+ * Get a list of observations.
6763
+ *
6764
+ * Consider using the [v2 observations endpoint](/api-reference#tag/observationsv2/GET/api/public/v2/observations) for cursor-based pagination and field selection.
6719
6765
  *
6720
6766
  * @param {LangfuseAPI.GetObservationsRequest} request
6721
6767
  * @param {Observations.RequestOptions} requestOptions - Request-specific configuration.
@@ -8160,7 +8206,7 @@ var Projects = class {
8160
8206
  * await client.projects.update("projectId", {
8161
8207
  * name: "name",
8162
8208
  * metadata: undefined,
8163
- * retention: 1
8209
+ * retention: undefined
8164
8210
  * })
8165
8211
  */
8166
8212
  update(projectId, request, requestOptions) {
@@ -10567,7 +10613,8 @@ var ScoreV2 = class {
10567
10613
  traceId,
10568
10614
  queueId,
10569
10615
  dataType,
10570
- traceTags
10616
+ traceTags,
10617
+ fields
10571
10618
  } = request;
10572
10619
  const _queryParams = {};
10573
10620
  if (page != null) {
@@ -10632,6 +10679,9 @@ var ScoreV2 = class {
10632
10679
  _queryParams["traceTags"] = traceTags;
10633
10680
  }
10634
10681
  }
10682
+ if (fields != null) {
10683
+ _queryParams["fields"] = fields;
10684
+ }
10635
10685
  let _headers = mergeHeaders(
10636
10686
  (_a2 = this._options) == null ? void 0 : _a2.headers,
10637
10687
  mergeOnlyDefinedHeaders({
@@ -12533,6 +12583,7 @@ export {
12533
12583
  ObservationType,
12534
12584
  PricingTierOperator,
12535
12585
  PromptType,
12586
+ ScoreConfigDataType,
12536
12587
  ScoreDataType,
12537
12588
  ScoreSource,
12538
12589
  ServiceUnavailableError,