@langfuse/core 4.2.0 → 4.3.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
@@ -235,7 +235,7 @@ var resetGlobalLogger = () => {
235
235
  // package.json
236
236
  var package_default = {
237
237
  name: "@langfuse/core",
238
- version: "4.2.0",
238
+ version: "4.3.0",
239
239
  description: "Core functions and utilities for Langfuse packages",
240
240
  type: "module",
241
241
  sideEffects: false,
@@ -318,7 +318,8 @@ var AnnotationQueueStatus = {
318
318
  // src/api/api/resources/annotationQueues/types/AnnotationQueueObjectType.ts
319
319
  var AnnotationQueueObjectType = {
320
320
  Trace: "TRACE",
321
- Observation: "OBSERVATION"
321
+ Observation: "OBSERVATION",
322
+ Session: "SESSION"
322
323
  };
323
324
 
324
325
  // src/api/api/resources/blobStorageIntegrations/index.ts
@@ -648,6 +649,9 @@ var models_exports = {};
648
649
  // src/api/api/resources/observations/index.ts
649
650
  var observations_exports = {};
650
651
 
652
+ // src/api/api/resources/opentelemetry/index.ts
653
+ var opentelemetry_exports = {};
654
+
651
655
  // src/api/api/resources/organizations/index.ts
652
656
  var organizations_exports = {};
653
657
  __export(organizations_exports, {
@@ -667,6 +671,15 @@ var projects_exports = {};
667
671
 
668
672
  // src/api/api/resources/prompts/index.ts
669
673
  var prompts_exports = {};
674
+ __export(prompts_exports, {
675
+ PromptType: () => PromptType
676
+ });
677
+
678
+ // src/api/api/resources/prompts/types/PromptType.ts
679
+ var PromptType = {
680
+ Chat: "chat",
681
+ Text: "text"
682
+ };
670
683
 
671
684
  // src/api/api/resources/scim/index.ts
672
685
  var scim_exports = {};
@@ -4734,7 +4747,7 @@ var Ingestion = class {
4734
4747
  /**
4735
4748
  * **Legacy endpoint for batch ingestion for Langfuse Observability.**
4736
4749
  *
4737
- * -> Please use the OpenTelemetry endpoint (`/api/public/otel`). Learn more: https://langfuse.com/integrations/native/opentelemetry
4750
+ * -> Please use the OpenTelemetry endpoint (`/api/public/otel/v1/traces`). Learn more: https://langfuse.com/integrations/native/opentelemetry
4738
4751
  *
4739
4752
  * Within each batch, there can be multiple events.
4740
4753
  * Each event has a type, an id, a timestamp, metadata and a body.
@@ -5508,7 +5521,9 @@ var Metrics = class {
5508
5521
  this._options = _options;
5509
5522
  }
5510
5523
  /**
5511
- * Get metrics from the Langfuse project using a query object
5524
+ * Get metrics from the Langfuse project using a query object.
5525
+ *
5526
+ * For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api).
5512
5527
  *
5513
5528
  * @param {LangfuseAPI.GetMetricsRequest} request
5514
5529
  * @param {Metrics.RequestOptions} requestOptions - Request-specific configuration.
@@ -6216,7 +6231,8 @@ var Observations = class {
6216
6231
  environment,
6217
6232
  fromStartTime,
6218
6233
  toStartTime,
6219
- version
6234
+ version,
6235
+ filter
6220
6236
  } = request;
6221
6237
  const _queryParams = {};
6222
6238
  if (page != null) {
@@ -6259,6 +6275,9 @@ var Observations = class {
6259
6275
  if (version != null) {
6260
6276
  _queryParams["version"] = version;
6261
6277
  }
6278
+ if (filter != null) {
6279
+ _queryParams["filter"] = filter;
6280
+ }
6262
6281
  let _headers = mergeHeaders(
6263
6282
  (_a2 = this._options) == null ? void 0 : _a2.headers,
6264
6283
  mergeOnlyDefinedHeaders({
@@ -6353,6 +6372,182 @@ var Observations = class {
6353
6372
  }
6354
6373
  };
6355
6374
 
6375
+ // src/api/api/resources/opentelemetry/client/Client.ts
6376
+ var Opentelemetry = class {
6377
+ constructor(_options) {
6378
+ this._options = _options;
6379
+ }
6380
+ /**
6381
+ * **OpenTelemetry Traces Ingestion Endpoint**
6382
+ *
6383
+ * This endpoint implements the OTLP/HTTP specification for trace ingestion, providing native OpenTelemetry integration for Langfuse Observability.
6384
+ *
6385
+ * **Supported Formats:**
6386
+ * - Binary Protobuf: `Content-Type: application/x-protobuf`
6387
+ * - JSON Protobuf: `Content-Type: application/json`
6388
+ * - Supports gzip compression via `Content-Encoding: gzip` header
6389
+ *
6390
+ * **Specification Compliance:**
6391
+ * - Conforms to [OTLP/HTTP Trace Export](https://opentelemetry.io/docs/specs/otlp/#otlphttp)
6392
+ * - Implements `ExportTraceServiceRequest` message format
6393
+ *
6394
+ * **Documentation:**
6395
+ * - Integration guide: https://langfuse.com/integrations/native/opentelemetry
6396
+ * - Data model: https://langfuse.com/docs/observability/data-model
6397
+ *
6398
+ * @param {LangfuseAPI.OtelTraceRequest} request
6399
+ * @param {Opentelemetry.RequestOptions} requestOptions - Request-specific configuration.
6400
+ *
6401
+ * @throws {@link LangfuseAPI.Error}
6402
+ * @throws {@link LangfuseAPI.UnauthorizedError}
6403
+ * @throws {@link LangfuseAPI.AccessDeniedError}
6404
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
6405
+ * @throws {@link LangfuseAPI.NotFoundError}
6406
+ *
6407
+ * @example
6408
+ * await client.opentelemetry.exportTraces({
6409
+ * resourceSpans: [{
6410
+ * resource: {
6411
+ * attributes: [{
6412
+ * key: "service.name",
6413
+ * value: {
6414
+ * stringValue: "my-service"
6415
+ * }
6416
+ * }, {
6417
+ * key: "service.version",
6418
+ * value: {
6419
+ * stringValue: "1.0.0"
6420
+ * }
6421
+ * }]
6422
+ * },
6423
+ * scopeSpans: [{
6424
+ * scope: {
6425
+ * name: "langfuse-sdk",
6426
+ * version: "2.60.3"
6427
+ * },
6428
+ * spans: [{
6429
+ * traceId: "0123456789abcdef0123456789abcdef",
6430
+ * spanId: "0123456789abcdef",
6431
+ * name: "my-operation",
6432
+ * kind: 1,
6433
+ * startTimeUnixNano: "1747872000000000000",
6434
+ * endTimeUnixNano: "1747872001000000000",
6435
+ * attributes: [{
6436
+ * key: "langfuse.observation.type",
6437
+ * value: {
6438
+ * stringValue: "generation"
6439
+ * }
6440
+ * }],
6441
+ * status: {}
6442
+ * }]
6443
+ * }]
6444
+ * }]
6445
+ * })
6446
+ */
6447
+ exportTraces(request, requestOptions) {
6448
+ return HttpResponsePromise.fromPromise(
6449
+ this.__exportTraces(request, requestOptions)
6450
+ );
6451
+ }
6452
+ async __exportTraces(request, requestOptions) {
6453
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
6454
+ let _headers = mergeHeaders(
6455
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
6456
+ mergeOnlyDefinedHeaders({
6457
+ Authorization: await this._getAuthorizationHeader(),
6458
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
6459
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
6460
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
6461
+ }),
6462
+ requestOptions == null ? void 0 : requestOptions.headers
6463
+ );
6464
+ const _response = await fetcher({
6465
+ url: url_exports.join(
6466
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
6467
+ "/api/public/otel/v1/traces"
6468
+ ),
6469
+ method: "POST",
6470
+ headers: _headers,
6471
+ contentType: "application/json",
6472
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
6473
+ requestType: "json",
6474
+ body: request,
6475
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
6476
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
6477
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
6478
+ });
6479
+ if (_response.ok) {
6480
+ return {
6481
+ data: _response.body,
6482
+ rawResponse: _response.rawResponse
6483
+ };
6484
+ }
6485
+ if (_response.error.reason === "status-code") {
6486
+ switch (_response.error.statusCode) {
6487
+ case 400:
6488
+ throw new Error2(
6489
+ _response.error.body,
6490
+ _response.rawResponse
6491
+ );
6492
+ case 401:
6493
+ throw new UnauthorizedError(
6494
+ _response.error.body,
6495
+ _response.rawResponse
6496
+ );
6497
+ case 403:
6498
+ throw new AccessDeniedError(
6499
+ _response.error.body,
6500
+ _response.rawResponse
6501
+ );
6502
+ case 405:
6503
+ throw new MethodNotAllowedError(
6504
+ _response.error.body,
6505
+ _response.rawResponse
6506
+ );
6507
+ case 404:
6508
+ throw new NotFoundError(
6509
+ _response.error.body,
6510
+ _response.rawResponse
6511
+ );
6512
+ default:
6513
+ throw new LangfuseAPIError({
6514
+ statusCode: _response.error.statusCode,
6515
+ body: _response.error.body,
6516
+ rawResponse: _response.rawResponse
6517
+ });
6518
+ }
6519
+ }
6520
+ switch (_response.error.reason) {
6521
+ case "non-json":
6522
+ throw new LangfuseAPIError({
6523
+ statusCode: _response.error.statusCode,
6524
+ body: _response.error.rawBody,
6525
+ rawResponse: _response.rawResponse
6526
+ });
6527
+ case "timeout":
6528
+ throw new LangfuseAPITimeoutError(
6529
+ "Timeout exceeded when calling POST /api/public/otel/v1/traces."
6530
+ );
6531
+ case "unknown":
6532
+ throw new LangfuseAPIError({
6533
+ message: _response.error.errorMessage,
6534
+ rawResponse: _response.rawResponse
6535
+ });
6536
+ }
6537
+ }
6538
+ async _getAuthorizationHeader() {
6539
+ const username = await Supplier.get(this._options.username);
6540
+ const password = await Supplier.get(this._options.password);
6541
+ if (username != null && password != null) {
6542
+ return BasicAuth.toAuthorizationHeader({
6543
+ username,
6544
+ password
6545
+ });
6546
+ }
6547
+ return void 0;
6548
+ }
6549
+ };
6550
+
6356
6551
  // src/api/api/resources/organizations/client/Client.ts
6357
6552
  var Organizations = class {
6358
6553
  constructor(_options) {
@@ -7661,7 +7856,9 @@ var Projects = class {
7661
7856
  *
7662
7857
  * @example
7663
7858
  * await client.projects.createApiKey("projectId", {
7664
- * note: undefined
7859
+ * note: undefined,
7860
+ * publicKey: undefined,
7861
+ * secretKey: undefined
7665
7862
  * })
7666
7863
  */
7667
7864
  createApiKey(projectId, request = {}, requestOptions) {
@@ -9468,6 +9665,120 @@ var ScoreConfigs = class {
9468
9665
  });
9469
9666
  }
9470
9667
  }
9668
+ /**
9669
+ * Update a score config
9670
+ *
9671
+ * @param {string} configId - The unique langfuse identifier of a score config
9672
+ * @param {LangfuseAPI.UpdateScoreConfigRequest} request
9673
+ * @param {ScoreConfigs.RequestOptions} requestOptions - Request-specific configuration.
9674
+ *
9675
+ * @throws {@link LangfuseAPI.Error}
9676
+ * @throws {@link LangfuseAPI.UnauthorizedError}
9677
+ * @throws {@link LangfuseAPI.AccessDeniedError}
9678
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
9679
+ * @throws {@link LangfuseAPI.NotFoundError}
9680
+ *
9681
+ * @example
9682
+ * await client.scoreConfigs.update("configId", {
9683
+ * isArchived: undefined,
9684
+ * name: undefined,
9685
+ * categories: undefined,
9686
+ * minValue: undefined,
9687
+ * maxValue: undefined,
9688
+ * description: undefined
9689
+ * })
9690
+ */
9691
+ update(configId, request, requestOptions) {
9692
+ return HttpResponsePromise.fromPromise(
9693
+ this.__update(configId, request, requestOptions)
9694
+ );
9695
+ }
9696
+ async __update(configId, request, requestOptions) {
9697
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
9698
+ let _headers = mergeHeaders(
9699
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
9700
+ mergeOnlyDefinedHeaders({
9701
+ Authorization: await this._getAuthorizationHeader(),
9702
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
9703
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
9704
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
9705
+ }),
9706
+ requestOptions == null ? void 0 : requestOptions.headers
9707
+ );
9708
+ const _response = await fetcher({
9709
+ url: url_exports.join(
9710
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
9711
+ `/api/public/score-configs/${encodeURIComponent(configId)}`
9712
+ ),
9713
+ method: "PATCH",
9714
+ headers: _headers,
9715
+ contentType: "application/json",
9716
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
9717
+ requestType: "json",
9718
+ body: request,
9719
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
9720
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
9721
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
9722
+ });
9723
+ if (_response.ok) {
9724
+ return {
9725
+ data: _response.body,
9726
+ rawResponse: _response.rawResponse
9727
+ };
9728
+ }
9729
+ if (_response.error.reason === "status-code") {
9730
+ switch (_response.error.statusCode) {
9731
+ case 400:
9732
+ throw new Error2(
9733
+ _response.error.body,
9734
+ _response.rawResponse
9735
+ );
9736
+ case 401:
9737
+ throw new UnauthorizedError(
9738
+ _response.error.body,
9739
+ _response.rawResponse
9740
+ );
9741
+ case 403:
9742
+ throw new AccessDeniedError(
9743
+ _response.error.body,
9744
+ _response.rawResponse
9745
+ );
9746
+ case 405:
9747
+ throw new MethodNotAllowedError(
9748
+ _response.error.body,
9749
+ _response.rawResponse
9750
+ );
9751
+ case 404:
9752
+ throw new NotFoundError(
9753
+ _response.error.body,
9754
+ _response.rawResponse
9755
+ );
9756
+ default:
9757
+ throw new LangfuseAPIError({
9758
+ statusCode: _response.error.statusCode,
9759
+ body: _response.error.body,
9760
+ rawResponse: _response.rawResponse
9761
+ });
9762
+ }
9763
+ }
9764
+ switch (_response.error.reason) {
9765
+ case "non-json":
9766
+ throw new LangfuseAPIError({
9767
+ statusCode: _response.error.statusCode,
9768
+ body: _response.error.rawBody,
9769
+ rawResponse: _response.rawResponse
9770
+ });
9771
+ case "timeout":
9772
+ throw new LangfuseAPITimeoutError(
9773
+ "Timeout exceeded when calling PATCH /api/public/score-configs/{configId}."
9774
+ );
9775
+ case "unknown":
9776
+ throw new LangfuseAPIError({
9777
+ message: _response.error.errorMessage,
9778
+ rawResponse: _response.rawResponse
9779
+ });
9780
+ }
9781
+ }
9471
9782
  async _getAuthorizationHeader() {
9472
9783
  const username = await Supplier.get(this._options.username);
9473
9784
  const password = await Supplier.get(this._options.password);
@@ -9809,6 +10120,7 @@ var Score = class {
9809
10120
  * comment: undefined,
9810
10121
  * metadata: undefined,
9811
10122
  * environment: undefined,
10123
+ * queueId: undefined,
9812
10124
  * dataType: undefined,
9813
10125
  * configId: undefined
9814
10126
  * })
@@ -10508,7 +10820,8 @@ var Trace = class {
10508
10820
  version,
10509
10821
  release,
10510
10822
  environment,
10511
- fields
10823
+ fields,
10824
+ filter
10512
10825
  } = request;
10513
10826
  const _queryParams = {};
10514
10827
  if (page != null) {
@@ -10558,6 +10871,9 @@ var Trace = class {
10558
10871
  if (fields != null) {
10559
10872
  _queryParams["fields"] = fields;
10560
10873
  }
10874
+ if (filter != null) {
10875
+ _queryParams["filter"] = filter;
10876
+ }
10561
10877
  let _headers = mergeHeaders(
10562
10878
  (_a2 = this._options) == null ? void 0 : _a2.headers,
10563
10879
  mergeOnlyDefinedHeaders({
@@ -10829,6 +11145,10 @@ var LangfuseAPIClient = class {
10829
11145
  var _a2;
10830
11146
  return (_a2 = this._observations) != null ? _a2 : this._observations = new Observations(this._options);
10831
11147
  }
11148
+ get opentelemetry() {
11149
+ var _a2;
11150
+ return (_a2 = this._opentelemetry) != null ? _a2 : this._opentelemetry = new Opentelemetry(this._options);
11151
+ }
10832
11152
  get organizations() {
10833
11153
  var _a2;
10834
11154
  return (_a2 = this._organizations) != null ? _a2 : this._organizations = new Organizations(this._options);
@@ -11061,6 +11381,7 @@ export {
11061
11381
  NotFoundError,
11062
11382
  ObservationLevel,
11063
11383
  ObservationType,
11384
+ PromptType,
11064
11385
  ScoreDataType,
11065
11386
  ScoreSource,
11066
11387
  ServiceUnavailableError,
@@ -11089,6 +11410,7 @@ export {
11089
11410
  metrics_exports as metrics,
11090
11411
  models_exports as models,
11091
11412
  observations_exports as observations,
11413
+ opentelemetry_exports as opentelemetry,
11092
11414
  organizations_exports as organizations,
11093
11415
  projects_exports as projects,
11094
11416
  promptVersion_exports as promptVersion,