@langfuse/core 5.4.0 → 5.4.1

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
@@ -276,7 +276,7 @@ var resetGlobalLogger = () => {
276
276
  // package.json
277
277
  var package_default = {
278
278
  name: "@langfuse/core",
279
- version: "5.4.0",
279
+ version: "5.4.1",
280
280
  description: "Core functions and utilities for Langfuse packages",
281
281
  type: "module",
282
282
  sideEffects: false,
@@ -385,8 +385,10 @@ var AnnotationQueueObjectType = {
385
385
  // src/api/api/resources/blobStorageIntegrations/index.ts
386
386
  var blobStorageIntegrations_exports = {};
387
387
  __export(blobStorageIntegrations_exports, {
388
+ BlobStorageExportFieldGroup: () => BlobStorageExportFieldGroup,
388
389
  BlobStorageExportFrequency: () => BlobStorageExportFrequency,
389
390
  BlobStorageExportMode: () => BlobStorageExportMode,
391
+ BlobStorageExportSource: () => BlobStorageExportSource,
390
392
  BlobStorageIntegrationFileType: () => BlobStorageIntegrationFileType,
391
393
  BlobStorageIntegrationType: () => BlobStorageIntegrationType,
392
394
  BlobStorageSyncStatus: () => BlobStorageSyncStatus
@@ -415,11 +417,34 @@ var BlobStorageExportMode = {
415
417
 
416
418
  // src/api/api/resources/blobStorageIntegrations/types/BlobStorageExportFrequency.ts
417
419
  var BlobStorageExportFrequency = {
420
+ Every20Minutes: "every_20_minutes",
418
421
  Hourly: "hourly",
419
422
  Daily: "daily",
420
423
  Weekly: "weekly"
421
424
  };
422
425
 
426
+ // src/api/api/resources/blobStorageIntegrations/types/BlobStorageExportSource.ts
427
+ var BlobStorageExportSource = {
428
+ LegacyTracesObservations: "LEGACY_TRACES_OBSERVATIONS",
429
+ ObservationsV2: "OBSERVATIONS_V2",
430
+ LegacyTracesAndEnrichedObservations: "LEGACY_TRACES_AND_ENRICHED_OBSERVATIONS"
431
+ };
432
+
433
+ // src/api/api/resources/blobStorageIntegrations/types/BlobStorageExportFieldGroup.ts
434
+ var BlobStorageExportFieldGroup = {
435
+ Core: "core",
436
+ Basic: "basic",
437
+ Time: "time",
438
+ Io: "io",
439
+ Metadata: "metadata",
440
+ Model: "model",
441
+ Usage: "usage",
442
+ Prompt: "prompt",
443
+ Metrics: "metrics",
444
+ Tools: "tools",
445
+ TraceContext: "trace_context"
446
+ };
447
+
423
448
  // src/api/api/resources/blobStorageIntegrations/types/BlobStorageSyncStatus.ts
424
449
  var BlobStorageSyncStatus = {
425
450
  Idle: "idle",
@@ -680,6 +705,7 @@ var ObservationType = {
680
705
  // src/api/api/resources/legacy/index.ts
681
706
  var legacy_exports = {};
682
707
  __export(legacy_exports, {
708
+ CreateScoreSource: () => CreateScoreSource,
683
709
  metricsV1: () => metricsV1_exports,
684
710
  observationsV1: () => observationsV1_exports,
685
711
  scoreV1: () => scoreV1_exports
@@ -693,6 +719,15 @@ var observationsV1_exports = {};
693
719
 
694
720
  // src/api/api/resources/legacy/resources/scoreV1/index.ts
695
721
  var scoreV1_exports = {};
722
+ __export(scoreV1_exports, {
723
+ CreateScoreSource: () => CreateScoreSource
724
+ });
725
+
726
+ // src/api/api/resources/legacy/resources/scoreV1/types/CreateScoreSource.ts
727
+ var CreateScoreSource = {
728
+ Api: "API",
729
+ Annotation: "ANNOTATION"
730
+ };
696
731
 
697
732
  // src/api/api/resources/llmConnections/index.ts
698
733
  var llmConnections_exports = {};
@@ -852,6 +887,297 @@ var sessions_exports = {};
852
887
  // src/api/api/resources/trace/index.ts
853
888
  var trace_exports = {};
854
889
 
890
+ // src/api/api/resources/unstable/index.ts
891
+ var unstable_exports = {};
892
+ __export(unstable_exports, {
893
+ AccessDeniedError: () => AccessDeniedError2,
894
+ BadRequestError: () => BadRequestError,
895
+ ConflictError: () => ConflictError,
896
+ EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator,
897
+ EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator,
898
+ EvaluationRuleMappingSource: () => EvaluationRuleMappingSource,
899
+ EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator,
900
+ EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator,
901
+ EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator,
902
+ EvaluationRuleStatus: () => EvaluationRuleStatus,
903
+ EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator,
904
+ EvaluationRuleTarget: () => EvaluationRuleTarget,
905
+ EvaluatorOutputDataType: () => EvaluatorOutputDataType,
906
+ EvaluatorScope: () => EvaluatorScope,
907
+ EvaluatorType: () => EvaluatorType,
908
+ InternalServerError: () => InternalServerError,
909
+ MethodNotAllowedError: () => MethodNotAllowedError2,
910
+ NotFoundError: () => NotFoundError2,
911
+ PublicApiErrorCode: () => PublicApiErrorCode,
912
+ TooManyRequestsError: () => TooManyRequestsError,
913
+ UnauthorizedError: () => UnauthorizedError2,
914
+ UnprocessableContentError: () => UnprocessableContentError,
915
+ commons: () => commons_exports2,
916
+ errors: () => errors_exports2,
917
+ evaluationRules: () => evaluationRules_exports,
918
+ evaluators: () => evaluators_exports
919
+ });
920
+
921
+ // src/api/api/resources/unstable/resources/commons/index.ts
922
+ var commons_exports2 = {};
923
+ __export(commons_exports2, {
924
+ EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator,
925
+ EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator,
926
+ EvaluationRuleMappingSource: () => EvaluationRuleMappingSource,
927
+ EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator,
928
+ EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator,
929
+ EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator,
930
+ EvaluationRuleStatus: () => EvaluationRuleStatus,
931
+ EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator,
932
+ EvaluationRuleTarget: () => EvaluationRuleTarget,
933
+ EvaluatorOutputDataType: () => EvaluatorOutputDataType,
934
+ EvaluatorScope: () => EvaluatorScope,
935
+ EvaluatorType: () => EvaluatorType
936
+ });
937
+
938
+ // src/api/api/resources/unstable/resources/commons/types/EvaluatorType.ts
939
+ var EvaluatorType = {
940
+ LlmAsJudge: "llm_as_judge"
941
+ };
942
+
943
+ // src/api/api/resources/unstable/resources/commons/types/EvaluatorScope.ts
944
+ var EvaluatorScope = {
945
+ Project: "project",
946
+ Managed: "managed"
947
+ };
948
+
949
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleTarget.ts
950
+ var EvaluationRuleTarget = {
951
+ Observation: "observation",
952
+ Experiment: "experiment"
953
+ };
954
+
955
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStatus.ts
956
+ var EvaluationRuleStatus = {
957
+ Active: "active",
958
+ Inactive: "inactive",
959
+ Paused: "paused"
960
+ };
961
+
962
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleMappingSource.ts
963
+ var EvaluationRuleMappingSource = {
964
+ Input: "input",
965
+ Output: "output",
966
+ Metadata: "metadata",
967
+ ExpectedOutput: "expected_output",
968
+ ExperimentItemMetadata: "experiment_item_metadata"
969
+ };
970
+
971
+ // src/api/api/resources/unstable/resources/commons/types/EvaluatorOutputDataType.ts
972
+ var EvaluatorOutputDataType = {
973
+ Numeric: "NUMERIC",
974
+ Boolean: "BOOLEAN",
975
+ Categorical: "CATEGORICAL"
976
+ };
977
+
978
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStringFilterOperator.ts
979
+ var EvaluationRuleStringFilterOperator = {
980
+ Equals: "=",
981
+ Contains: "contains",
982
+ DoesNotContain: "does not contain",
983
+ StartsWith: "starts with",
984
+ EndsWith: "ends with"
985
+ };
986
+
987
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNumberFilterOperator.ts
988
+ var EvaluationRuleNumberFilterOperator = {
989
+ Equals: "=",
990
+ GreaterThan: ">",
991
+ LessThan: "<",
992
+ GreaterThanOrEqual: ">=",
993
+ LessThanOrEqual: "<="
994
+ };
995
+
996
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleOptionsFilterOperator.ts
997
+ var EvaluationRuleOptionsFilterOperator = {
998
+ AnyOf: "any of",
999
+ NoneOf: "none of"
1000
+ };
1001
+
1002
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleArrayOptionsFilterOperator.ts
1003
+ var EvaluationRuleArrayOptionsFilterOperator = {
1004
+ AnyOf: "any of",
1005
+ NoneOf: "none of",
1006
+ AllOf: "all of"
1007
+ };
1008
+
1009
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleBooleanFilterOperator.ts
1010
+ var EvaluationRuleBooleanFilterOperator = {
1011
+ Equals: "=",
1012
+ NotEquals: "<>"
1013
+ };
1014
+
1015
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNullFilterOperator.ts
1016
+ var EvaluationRuleNullFilterOperator = {
1017
+ IsNull: "is null",
1018
+ IsNotNull: "is not null"
1019
+ };
1020
+
1021
+ // src/api/api/resources/unstable/resources/errors/index.ts
1022
+ var errors_exports2 = {};
1023
+ __export(errors_exports2, {
1024
+ AccessDeniedError: () => AccessDeniedError2,
1025
+ BadRequestError: () => BadRequestError,
1026
+ ConflictError: () => ConflictError,
1027
+ InternalServerError: () => InternalServerError,
1028
+ MethodNotAllowedError: () => MethodNotAllowedError2,
1029
+ NotFoundError: () => NotFoundError2,
1030
+ PublicApiErrorCode: () => PublicApiErrorCode,
1031
+ TooManyRequestsError: () => TooManyRequestsError,
1032
+ UnauthorizedError: () => UnauthorizedError2,
1033
+ UnprocessableContentError: () => UnprocessableContentError
1034
+ });
1035
+
1036
+ // src/api/api/resources/unstable/resources/errors/types/PublicApiErrorCode.ts
1037
+ var PublicApiErrorCode = {
1038
+ AuthenticationFailed: "authentication_failed",
1039
+ AccessDenied: "access_denied",
1040
+ InvalidRequest: "invalid_request",
1041
+ InvalidQuery: "invalid_query",
1042
+ InvalidBody: "invalid_body",
1043
+ InvalidFilterValue: "invalid_filter_value",
1044
+ InvalidJsonPath: "invalid_json_path",
1045
+ InvalidVariableMapping: "invalid_variable_mapping",
1046
+ MissingVariableMapping: "missing_variable_mapping",
1047
+ DuplicateVariableMapping: "duplicate_variable_mapping",
1048
+ ResourceNotFound: "resource_not_found",
1049
+ NameConflict: "name_conflict",
1050
+ EvaluatorPreflightFailed: "evaluator_preflight_failed",
1051
+ Conflict: "conflict",
1052
+ UnprocessableContent: "unprocessable_content",
1053
+ RateLimited: "rate_limited",
1054
+ MethodNotAllowed: "method_not_allowed",
1055
+ InternalError: "internal_error"
1056
+ };
1057
+
1058
+ // src/api/api/resources/unstable/resources/errors/errors/BadRequestError.ts
1059
+ var BadRequestError = class _BadRequestError extends LangfuseAPIError {
1060
+ constructor(body, rawResponse) {
1061
+ super({
1062
+ message: "BadRequestError",
1063
+ statusCode: 400,
1064
+ body,
1065
+ rawResponse
1066
+ });
1067
+ Object.setPrototypeOf(this, _BadRequestError.prototype);
1068
+ }
1069
+ };
1070
+
1071
+ // src/api/api/resources/unstable/resources/errors/errors/UnauthorizedError.ts
1072
+ var UnauthorizedError2 = class _UnauthorizedError extends LangfuseAPIError {
1073
+ constructor(body, rawResponse) {
1074
+ super({
1075
+ message: "UnauthorizedError",
1076
+ statusCode: 401,
1077
+ body,
1078
+ rawResponse
1079
+ });
1080
+ Object.setPrototypeOf(this, _UnauthorizedError.prototype);
1081
+ }
1082
+ };
1083
+
1084
+ // src/api/api/resources/unstable/resources/errors/errors/AccessDeniedError.ts
1085
+ var AccessDeniedError2 = class _AccessDeniedError extends LangfuseAPIError {
1086
+ constructor(body, rawResponse) {
1087
+ super({
1088
+ message: "AccessDeniedError",
1089
+ statusCode: 403,
1090
+ body,
1091
+ rawResponse
1092
+ });
1093
+ Object.setPrototypeOf(this, _AccessDeniedError.prototype);
1094
+ }
1095
+ };
1096
+
1097
+ // src/api/api/resources/unstable/resources/errors/errors/NotFoundError.ts
1098
+ var NotFoundError2 = class _NotFoundError extends LangfuseAPIError {
1099
+ constructor(body, rawResponse) {
1100
+ super({
1101
+ message: "NotFoundError",
1102
+ statusCode: 404,
1103
+ body,
1104
+ rawResponse
1105
+ });
1106
+ Object.setPrototypeOf(this, _NotFoundError.prototype);
1107
+ }
1108
+ };
1109
+
1110
+ // src/api/api/resources/unstable/resources/errors/errors/MethodNotAllowedError.ts
1111
+ var MethodNotAllowedError2 = class _MethodNotAllowedError extends LangfuseAPIError {
1112
+ constructor(body, rawResponse) {
1113
+ super({
1114
+ message: "MethodNotAllowedError",
1115
+ statusCode: 405,
1116
+ body,
1117
+ rawResponse
1118
+ });
1119
+ Object.setPrototypeOf(this, _MethodNotAllowedError.prototype);
1120
+ }
1121
+ };
1122
+
1123
+ // src/api/api/resources/unstable/resources/errors/errors/ConflictError.ts
1124
+ var ConflictError = class _ConflictError extends LangfuseAPIError {
1125
+ constructor(body, rawResponse) {
1126
+ super({
1127
+ message: "ConflictError",
1128
+ statusCode: 409,
1129
+ body,
1130
+ rawResponse
1131
+ });
1132
+ Object.setPrototypeOf(this, _ConflictError.prototype);
1133
+ }
1134
+ };
1135
+
1136
+ // src/api/api/resources/unstable/resources/errors/errors/UnprocessableContentError.ts
1137
+ var UnprocessableContentError = class _UnprocessableContentError extends LangfuseAPIError {
1138
+ constructor(body, rawResponse) {
1139
+ super({
1140
+ message: "UnprocessableContentError",
1141
+ statusCode: 422,
1142
+ body,
1143
+ rawResponse
1144
+ });
1145
+ Object.setPrototypeOf(this, _UnprocessableContentError.prototype);
1146
+ }
1147
+ };
1148
+
1149
+ // src/api/api/resources/unstable/resources/errors/errors/TooManyRequestsError.ts
1150
+ var TooManyRequestsError = class _TooManyRequestsError extends LangfuseAPIError {
1151
+ constructor(body, rawResponse) {
1152
+ super({
1153
+ message: "TooManyRequestsError",
1154
+ statusCode: 429,
1155
+ body,
1156
+ rawResponse
1157
+ });
1158
+ Object.setPrototypeOf(this, _TooManyRequestsError.prototype);
1159
+ }
1160
+ };
1161
+
1162
+ // src/api/api/resources/unstable/resources/errors/errors/InternalServerError.ts
1163
+ var InternalServerError = class _InternalServerError extends LangfuseAPIError {
1164
+ constructor(body, rawResponse) {
1165
+ super({
1166
+ message: "InternalServerError",
1167
+ statusCode: 500,
1168
+ body,
1169
+ rawResponse
1170
+ });
1171
+ Object.setPrototypeOf(this, _InternalServerError.prototype);
1172
+ }
1173
+ };
1174
+
1175
+ // src/api/api/resources/unstable/resources/evaluationRules/index.ts
1176
+ var evaluationRules_exports = {};
1177
+
1178
+ // src/api/api/resources/unstable/resources/evaluators/index.ts
1179
+ var evaluators_exports = {};
1180
+
855
1181
  // src/api/api/resources/utils/index.ts
856
1182
  var utils_exports = {};
857
1183
  __export(utils_exports, {
@@ -2837,13 +3163,15 @@ var BlobStorageIntegrations = class {
2837
3163
  * accessKeyId: undefined,
2838
3164
  * secretAccessKey: undefined,
2839
3165
  * prefix: undefined,
2840
- * exportFrequency: "hourly",
3166
+ * exportFrequency: "every_20_minutes",
2841
3167
  * enabled: true,
2842
3168
  * forcePathStyle: true,
2843
3169
  * fileType: "JSON",
2844
3170
  * exportMode: "FULL_HISTORY",
2845
3171
  * exportStartDate: undefined,
2846
- * compressed: undefined
3172
+ * compressed: undefined,
3173
+ * exportSource: undefined,
3174
+ * exportFieldGroups: undefined
2847
3175
  * })
2848
3176
  */
2849
3177
  upsertBlobStorageIntegration(request, requestOptions) {
@@ -5647,7 +5975,8 @@ var ScoreV1 = class {
5647
5975
  * environment: undefined,
5648
5976
  * queueId: undefined,
5649
5977
  * dataType: undefined,
5650
- * configId: undefined
5978
+ * configId: undefined,
5979
+ * source: undefined
5651
5980
  * })
5652
5981
  */
5653
5982
  create(request, requestOptions) {
@@ -6104,6 +6433,109 @@ var LlmConnections = class {
6104
6433
  });
6105
6434
  }
6106
6435
  }
6436
+ /**
6437
+ * Delete an LLM connection by id. Evaluators that depend on the deleted connection are automatically paused.
6438
+ *
6439
+ * @param {string} id
6440
+ * @param {LlmConnections.RequestOptions} requestOptions - Request-specific configuration.
6441
+ *
6442
+ * @throws {@link LangfuseAPI.Error}
6443
+ * @throws {@link LangfuseAPI.UnauthorizedError}
6444
+ * @throws {@link LangfuseAPI.AccessDeniedError}
6445
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
6446
+ * @throws {@link LangfuseAPI.NotFoundError}
6447
+ *
6448
+ * @example
6449
+ * await client.llmConnections.delete("id")
6450
+ */
6451
+ delete(id, requestOptions) {
6452
+ return HttpResponsePromise.fromPromise(
6453
+ this.__delete(id, requestOptions)
6454
+ );
6455
+ }
6456
+ async __delete(id, requestOptions) {
6457
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
6458
+ let _headers = mergeHeaders(
6459
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
6460
+ mergeOnlyDefinedHeaders({
6461
+ Authorization: await this._getAuthorizationHeader(),
6462
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
6463
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
6464
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
6465
+ }),
6466
+ requestOptions == null ? void 0 : requestOptions.headers
6467
+ );
6468
+ const _response = await fetcher({
6469
+ url: url_exports.join(
6470
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
6471
+ `/api/public/llm-connections/${encodeURIComponent(id)}`
6472
+ ),
6473
+ method: "DELETE",
6474
+ headers: _headers,
6475
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
6476
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
6477
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
6478
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
6479
+ });
6480
+ if (_response.ok) {
6481
+ return {
6482
+ data: _response.body,
6483
+ rawResponse: _response.rawResponse
6484
+ };
6485
+ }
6486
+ if (_response.error.reason === "status-code") {
6487
+ switch (_response.error.statusCode) {
6488
+ case 400:
6489
+ throw new Error2(
6490
+ _response.error.body,
6491
+ _response.rawResponse
6492
+ );
6493
+ case 401:
6494
+ throw new UnauthorizedError(
6495
+ _response.error.body,
6496
+ _response.rawResponse
6497
+ );
6498
+ case 403:
6499
+ throw new AccessDeniedError(
6500
+ _response.error.body,
6501
+ _response.rawResponse
6502
+ );
6503
+ case 405:
6504
+ throw new MethodNotAllowedError(
6505
+ _response.error.body,
6506
+ _response.rawResponse
6507
+ );
6508
+ case 404:
6509
+ throw new NotFoundError(
6510
+ _response.error.body,
6511
+ _response.rawResponse
6512
+ );
6513
+ default:
6514
+ throw new LangfuseAPIError({
6515
+ statusCode: _response.error.statusCode,
6516
+ body: _response.error.body,
6517
+ rawResponse: _response.rawResponse
6518
+ });
6519
+ }
6520
+ }
6521
+ switch (_response.error.reason) {
6522
+ case "non-json":
6523
+ throw new LangfuseAPIError({
6524
+ statusCode: _response.error.statusCode,
6525
+ body: _response.error.rawBody,
6526
+ rawResponse: _response.rawResponse
6527
+ });
6528
+ case "timeout":
6529
+ throw new LangfuseAPITimeoutError(
6530
+ "Timeout exceeded when calling DELETE /api/public/llm-connections/{id}."
6531
+ );
6532
+ case "unknown":
6533
+ throw new LangfuseAPIError({
6534
+ message: _response.error.errorMessage,
6535
+ rawResponse: _response.rawResponse
6536
+ });
6537
+ }
6538
+ }
6107
6539
  async _getAuthorizationHeader() {
6108
6540
  const username = await Supplier.get(this._options.username);
6109
6541
  const password = await Supplier.get(this._options.password);
@@ -7154,9 +7586,10 @@ var Observations = class {
7154
7586
  * - `io` - input, output
7155
7587
  * - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
7156
7588
  * - `model` - providedModelName, internalModelId, modelParameters
7157
- * - `usage` - usageDetails, costDetails, totalCost
7589
+ * - `usage` - usageDetails, costDetails, totalCost, usagePricingTierName
7158
7590
  * - `prompt` - promptId, promptName, promptVersion
7159
7591
  * - `metrics` - latency, timeToFirstToken
7592
+ * - `trace_context` - tags, release, traceName
7160
7593
  *
7161
7594
  * If not specified, `core` and `basic` field groups are returned.
7162
7595
  *
@@ -12056,34 +12489,1442 @@ var Trace = class {
12056
12489
  }
12057
12490
  };
12058
12491
 
12059
- // src/api/Client.ts
12060
- var LangfuseAPIClient = class {
12492
+ // src/api/api/resources/unstable/resources/evaluationRules/client/Client.ts
12493
+ var EvaluationRules = class {
12061
12494
  constructor(_options) {
12062
- this._options = {
12063
- ..._options,
12064
- headers: mergeHeaders(
12065
- {
12066
- "X-Langfuse-Sdk-Name": _options == null ? void 0 : _options.xLangfuseSdkName,
12067
- "X-Langfuse-Sdk-Version": _options == null ? void 0 : _options.xLangfuseSdkVersion,
12068
- "X-Langfuse-Public-Key": _options == null ? void 0 : _options.xLangfusePublicKey
12069
- },
12070
- _options == null ? void 0 : _options.headers
12071
- )
12072
- };
12073
- }
12074
- get annotationQueues() {
12075
- var _a2;
12076
- return (_a2 = this._annotationQueues) != null ? _a2 : this._annotationQueues = new AnnotationQueues(this._options);
12077
- }
12078
- get blobStorageIntegrations() {
12079
- var _a2;
12080
- return (_a2 = this._blobStorageIntegrations) != null ? _a2 : this._blobStorageIntegrations = new BlobStorageIntegrations(
12081
- this._options
12082
- );
12083
- }
12084
- get comments() {
12085
- var _a2;
12086
- return (_a2 = this._comments) != null ? _a2 : this._comments = new Comments(this._options);
12495
+ this._options = _options;
12496
+ }
12497
+ /**
12498
+ * Create an evaluation rule.
12499
+ *
12500
+ * An evaluation rule defines **what** incoming data should be evaluated and **how prompt variables should be populated** from that data.
12501
+ *
12502
+ * Use this resource after choosing an evaluator from the evaluator endpoints.
12503
+ *
12504
+ * Key rules:
12505
+ * - `name` must be unique within the project for public evaluation rules
12506
+ * - `target` must be `observation` or `experiment`
12507
+ * - `evaluator.name` + `evaluator.scope` must identify an existing evaluator family returned by the evaluator endpoints
12508
+ * - Langfuse resolves that family to its latest version before saving the evaluation rule
12509
+ * - for `target=experiment`, use dataset `id` values from `GET /api/public/v2/datasets` when filtering by `datasetId`
12510
+ * - every evaluator prompt variable must be mapped exactly once
12511
+ * - `expected_output` and `experiment_item_metadata` mappings are only valid for `target=experiment`
12512
+ * - if `enabled=true`, Langfuse validates that the referenced evaluator can currently run
12513
+ * - at most 50 evaluation rules can be effectively active in one project at the same time
12514
+ *
12515
+ * If an evaluation rule with the same `name` already exists in the project, the API returns `409`.
12516
+ * In that case, update the existing resource with `PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}` instead of creating a second one.
12517
+ *
12518
+ * If enabling this resource would exceed the 50-active limit, the API also returns `409`.
12519
+ * In that case, disable or pause another active evaluation rule before enabling a new one.
12520
+ *
12521
+ * Current scope:
12522
+ * - evaluation rules are live-ingestion rules only
12523
+ * - they do not trigger historical backfills
12524
+ *
12525
+ * Recovery guidance:
12526
+ * - `400 invalid_filter_value`: fix the filter `column` or `value` using `details.column`, `details.invalidValues`, and `details.allowedValues`
12527
+ * - `400 invalid_filter_value` with `details.column=datasetId`: call `GET /api/public/v2/datasets`, then retry with dataset `id` values from that response
12528
+ * - `400 missing_variable_mapping`: fetch the evaluator again and make sure every variable in `variables` appears exactly once in `mapping`
12529
+ * - `400 duplicate_variable_mapping`: remove repeated mappings for the same variable
12530
+ * - `400 invalid_variable_mapping`: switch to a valid `source` for the selected `target`, or fix the variable name
12531
+ * - `400 invalid_json_path`: remove or correct the `jsonPath`
12532
+ * - `422 evaluator_preflight_failed`: the selected evaluator cannot run with the resolved model configuration. Fix the evaluator/default model setup, then retry the create request.
12533
+ *
12534
+ * @param {LangfuseAPI.unstable.CreateEvaluationRuleRequest} request
12535
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
12536
+ *
12537
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
12538
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
12539
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
12540
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
12541
+ * @throws {@link LangfuseAPI.unstable.ConflictError}
12542
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
12543
+ * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
12544
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
12545
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
12546
+ * @throws {@link LangfuseAPI.Error}
12547
+ * @throws {@link LangfuseAPI.UnauthorizedError}
12548
+ * @throws {@link LangfuseAPI.AccessDeniedError}
12549
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
12550
+ * @throws {@link LangfuseAPI.NotFoundError}
12551
+ *
12552
+ * @example
12553
+ * await client.unstable.evaluationRules.create({
12554
+ * name: "answer-correctness-live",
12555
+ * evaluator: {
12556
+ * name: "answer-correctness",
12557
+ * scope: "project"
12558
+ * },
12559
+ * target: "observation",
12560
+ * enabled: true,
12561
+ * sampling: 1,
12562
+ * filter: [{
12563
+ * type: "stringOptions",
12564
+ * column: "type",
12565
+ * operator: "any of",
12566
+ * value: ["GENERATION"]
12567
+ * }],
12568
+ * mapping: [{
12569
+ * variable: "input",
12570
+ * source: "input"
12571
+ * }, {
12572
+ * variable: "output",
12573
+ * source: "output"
12574
+ * }]
12575
+ * })
12576
+ *
12577
+ * @example
12578
+ * await client.unstable.evaluationRules.create({
12579
+ * name: "experiment-expected-output-match",
12580
+ * evaluator: {
12581
+ * name: "expected-output-match",
12582
+ * scope: "project"
12583
+ * },
12584
+ * target: "experiment",
12585
+ * enabled: true,
12586
+ * sampling: 0.5,
12587
+ * filter: [{
12588
+ * type: "stringOptions",
12589
+ * column: "datasetId",
12590
+ * operator: "any of",
12591
+ * value: ["550e8400-e29b-41d4-a716-446655440000"]
12592
+ * }],
12593
+ * mapping: [{
12594
+ * variable: "output",
12595
+ * source: "output"
12596
+ * }, {
12597
+ * variable: "expected_output",
12598
+ * source: "expected_output"
12599
+ * }]
12600
+ * })
12601
+ */
12602
+ create(request, requestOptions) {
12603
+ return HttpResponsePromise.fromPromise(
12604
+ this.__create(request, requestOptions)
12605
+ );
12606
+ }
12607
+ async __create(request, requestOptions) {
12608
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
12609
+ let _headers = mergeHeaders(
12610
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
12611
+ mergeOnlyDefinedHeaders({
12612
+ Authorization: await this._getAuthorizationHeader(),
12613
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
12614
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
12615
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
12616
+ }),
12617
+ requestOptions == null ? void 0 : requestOptions.headers
12618
+ );
12619
+ const _response = await fetcher({
12620
+ url: url_exports.join(
12621
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
12622
+ "/api/public/unstable/evaluation-rules"
12623
+ ),
12624
+ method: "POST",
12625
+ headers: _headers,
12626
+ contentType: "application/json",
12627
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
12628
+ requestType: "json",
12629
+ body: request,
12630
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
12631
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
12632
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
12633
+ });
12634
+ if (_response.ok) {
12635
+ return {
12636
+ data: _response.body,
12637
+ rawResponse: _response.rawResponse
12638
+ };
12639
+ }
12640
+ if (_response.error.reason === "status-code") {
12641
+ switch (_response.error.statusCode) {
12642
+ case 400:
12643
+ throw new unstable_exports.BadRequestError(
12644
+ _response.error.body,
12645
+ _response.rawResponse
12646
+ );
12647
+ case 401:
12648
+ throw new unstable_exports.UnauthorizedError(
12649
+ _response.error.body,
12650
+ _response.rawResponse
12651
+ );
12652
+ case 403:
12653
+ throw new unstable_exports.AccessDeniedError(
12654
+ _response.error.body,
12655
+ _response.rawResponse
12656
+ );
12657
+ case 404:
12658
+ throw new unstable_exports.NotFoundError(
12659
+ _response.error.body,
12660
+ _response.rawResponse
12661
+ );
12662
+ case 409:
12663
+ throw new unstable_exports.ConflictError(
12664
+ _response.error.body,
12665
+ _response.rawResponse
12666
+ );
12667
+ case 405:
12668
+ throw new unstable_exports.MethodNotAllowedError(
12669
+ _response.error.body,
12670
+ _response.rawResponse
12671
+ );
12672
+ case 422:
12673
+ throw new unstable_exports.UnprocessableContentError(
12674
+ _response.error.body,
12675
+ _response.rawResponse
12676
+ );
12677
+ case 429:
12678
+ throw new unstable_exports.TooManyRequestsError(
12679
+ _response.error.body,
12680
+ _response.rawResponse
12681
+ );
12682
+ case 500:
12683
+ throw new unstable_exports.InternalServerError(
12684
+ _response.error.body,
12685
+ _response.rawResponse
12686
+ );
12687
+ case 400:
12688
+ throw new Error2(
12689
+ _response.error.body,
12690
+ _response.rawResponse
12691
+ );
12692
+ case 401:
12693
+ throw new UnauthorizedError(
12694
+ _response.error.body,
12695
+ _response.rawResponse
12696
+ );
12697
+ case 403:
12698
+ throw new AccessDeniedError(
12699
+ _response.error.body,
12700
+ _response.rawResponse
12701
+ );
12702
+ case 405:
12703
+ throw new MethodNotAllowedError(
12704
+ _response.error.body,
12705
+ _response.rawResponse
12706
+ );
12707
+ case 404:
12708
+ throw new NotFoundError(
12709
+ _response.error.body,
12710
+ _response.rawResponse
12711
+ );
12712
+ default:
12713
+ throw new LangfuseAPIError({
12714
+ statusCode: _response.error.statusCode,
12715
+ body: _response.error.body,
12716
+ rawResponse: _response.rawResponse
12717
+ });
12718
+ }
12719
+ }
12720
+ switch (_response.error.reason) {
12721
+ case "non-json":
12722
+ throw new LangfuseAPIError({
12723
+ statusCode: _response.error.statusCode,
12724
+ body: _response.error.rawBody,
12725
+ rawResponse: _response.rawResponse
12726
+ });
12727
+ case "timeout":
12728
+ throw new LangfuseAPITimeoutError(
12729
+ "Timeout exceeded when calling POST /api/public/unstable/evaluation-rules."
12730
+ );
12731
+ case "unknown":
12732
+ throw new LangfuseAPIError({
12733
+ message: _response.error.errorMessage,
12734
+ rawResponse: _response.rawResponse
12735
+ });
12736
+ }
12737
+ }
12738
+ /**
12739
+ * List evaluation rules in the authenticated project.
12740
+ *
12741
+ * Each item describes one live evaluation rule and its effective runtime status.
12742
+ *
12743
+ * @param {LangfuseAPI.unstable.ListEvaluationRulesRequest} request
12744
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
12745
+ *
12746
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
12747
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
12748
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
12749
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
12750
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
12751
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
12752
+ * @throws {@link LangfuseAPI.Error}
12753
+ * @throws {@link LangfuseAPI.UnauthorizedError}
12754
+ * @throws {@link LangfuseAPI.AccessDeniedError}
12755
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
12756
+ * @throws {@link LangfuseAPI.NotFoundError}
12757
+ *
12758
+ * @example
12759
+ * await client.unstable.evaluationRules.list()
12760
+ */
12761
+ list(request = {}, requestOptions) {
12762
+ return HttpResponsePromise.fromPromise(
12763
+ this.__list(request, requestOptions)
12764
+ );
12765
+ }
12766
+ async __list(request = {}, requestOptions) {
12767
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
12768
+ const { page, limit } = request;
12769
+ const _queryParams = {};
12770
+ if (page != null) {
12771
+ _queryParams["page"] = page.toString();
12772
+ }
12773
+ if (limit != null) {
12774
+ _queryParams["limit"] = limit.toString();
12775
+ }
12776
+ let _headers = mergeHeaders(
12777
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
12778
+ mergeOnlyDefinedHeaders({
12779
+ Authorization: await this._getAuthorizationHeader(),
12780
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
12781
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
12782
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
12783
+ }),
12784
+ requestOptions == null ? void 0 : requestOptions.headers
12785
+ );
12786
+ const _response = await fetcher({
12787
+ url: url_exports.join(
12788
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
12789
+ "/api/public/unstable/evaluation-rules"
12790
+ ),
12791
+ method: "GET",
12792
+ headers: _headers,
12793
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
12794
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
12795
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
12796
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
12797
+ });
12798
+ if (_response.ok) {
12799
+ return {
12800
+ data: _response.body,
12801
+ rawResponse: _response.rawResponse
12802
+ };
12803
+ }
12804
+ if (_response.error.reason === "status-code") {
12805
+ switch (_response.error.statusCode) {
12806
+ case 400:
12807
+ throw new unstable_exports.BadRequestError(
12808
+ _response.error.body,
12809
+ _response.rawResponse
12810
+ );
12811
+ case 401:
12812
+ throw new unstable_exports.UnauthorizedError(
12813
+ _response.error.body,
12814
+ _response.rawResponse
12815
+ );
12816
+ case 403:
12817
+ throw new unstable_exports.AccessDeniedError(
12818
+ _response.error.body,
12819
+ _response.rawResponse
12820
+ );
12821
+ case 405:
12822
+ throw new unstable_exports.MethodNotAllowedError(
12823
+ _response.error.body,
12824
+ _response.rawResponse
12825
+ );
12826
+ case 429:
12827
+ throw new unstable_exports.TooManyRequestsError(
12828
+ _response.error.body,
12829
+ _response.rawResponse
12830
+ );
12831
+ case 500:
12832
+ throw new unstable_exports.InternalServerError(
12833
+ _response.error.body,
12834
+ _response.rawResponse
12835
+ );
12836
+ case 400:
12837
+ throw new Error2(
12838
+ _response.error.body,
12839
+ _response.rawResponse
12840
+ );
12841
+ case 401:
12842
+ throw new UnauthorizedError(
12843
+ _response.error.body,
12844
+ _response.rawResponse
12845
+ );
12846
+ case 403:
12847
+ throw new AccessDeniedError(
12848
+ _response.error.body,
12849
+ _response.rawResponse
12850
+ );
12851
+ case 405:
12852
+ throw new MethodNotAllowedError(
12853
+ _response.error.body,
12854
+ _response.rawResponse
12855
+ );
12856
+ case 404:
12857
+ throw new NotFoundError(
12858
+ _response.error.body,
12859
+ _response.rawResponse
12860
+ );
12861
+ default:
12862
+ throw new LangfuseAPIError({
12863
+ statusCode: _response.error.statusCode,
12864
+ body: _response.error.body,
12865
+ rawResponse: _response.rawResponse
12866
+ });
12867
+ }
12868
+ }
12869
+ switch (_response.error.reason) {
12870
+ case "non-json":
12871
+ throw new LangfuseAPIError({
12872
+ statusCode: _response.error.statusCode,
12873
+ body: _response.error.rawBody,
12874
+ rawResponse: _response.rawResponse
12875
+ });
12876
+ case "timeout":
12877
+ throw new LangfuseAPITimeoutError(
12878
+ "Timeout exceeded when calling GET /api/public/unstable/evaluation-rules."
12879
+ );
12880
+ case "unknown":
12881
+ throw new LangfuseAPIError({
12882
+ message: _response.error.errorMessage,
12883
+ rawResponse: _response.rawResponse
12884
+ });
12885
+ }
12886
+ }
12887
+ /**
12888
+ * Get one evaluation rule by its identifier.
12889
+ *
12890
+ * Use this endpoint to inspect the current evaluator, target, mapping, filters, and effective runtime status.
12891
+ *
12892
+ * @param {string} evaluationRuleId - Evaluation rule identifier returned by the evaluation rule endpoints.
12893
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
12894
+ *
12895
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
12896
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
12897
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
12898
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
12899
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
12900
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
12901
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
12902
+ * @throws {@link LangfuseAPI.Error}
12903
+ * @throws {@link LangfuseAPI.UnauthorizedError}
12904
+ * @throws {@link LangfuseAPI.AccessDeniedError}
12905
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
12906
+ * @throws {@link LangfuseAPI.NotFoundError}
12907
+ *
12908
+ * @example
12909
+ * await client.unstable.evaluationRules.get("evaluationRuleId")
12910
+ */
12911
+ get(evaluationRuleId, requestOptions) {
12912
+ return HttpResponsePromise.fromPromise(
12913
+ this.__get(evaluationRuleId, requestOptions)
12914
+ );
12915
+ }
12916
+ async __get(evaluationRuleId, requestOptions) {
12917
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
12918
+ let _headers = mergeHeaders(
12919
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
12920
+ mergeOnlyDefinedHeaders({
12921
+ Authorization: await this._getAuthorizationHeader(),
12922
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
12923
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
12924
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
12925
+ }),
12926
+ requestOptions == null ? void 0 : requestOptions.headers
12927
+ );
12928
+ const _response = await fetcher({
12929
+ url: url_exports.join(
12930
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
12931
+ `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
12932
+ ),
12933
+ method: "GET",
12934
+ headers: _headers,
12935
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
12936
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
12937
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
12938
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
12939
+ });
12940
+ if (_response.ok) {
12941
+ return {
12942
+ data: _response.body,
12943
+ rawResponse: _response.rawResponse
12944
+ };
12945
+ }
12946
+ if (_response.error.reason === "status-code") {
12947
+ switch (_response.error.statusCode) {
12948
+ case 400:
12949
+ throw new unstable_exports.BadRequestError(
12950
+ _response.error.body,
12951
+ _response.rawResponse
12952
+ );
12953
+ case 401:
12954
+ throw new unstable_exports.UnauthorizedError(
12955
+ _response.error.body,
12956
+ _response.rawResponse
12957
+ );
12958
+ case 403:
12959
+ throw new unstable_exports.AccessDeniedError(
12960
+ _response.error.body,
12961
+ _response.rawResponse
12962
+ );
12963
+ case 404:
12964
+ throw new unstable_exports.NotFoundError(
12965
+ _response.error.body,
12966
+ _response.rawResponse
12967
+ );
12968
+ case 405:
12969
+ throw new unstable_exports.MethodNotAllowedError(
12970
+ _response.error.body,
12971
+ _response.rawResponse
12972
+ );
12973
+ case 429:
12974
+ throw new unstable_exports.TooManyRequestsError(
12975
+ _response.error.body,
12976
+ _response.rawResponse
12977
+ );
12978
+ case 500:
12979
+ throw new unstable_exports.InternalServerError(
12980
+ _response.error.body,
12981
+ _response.rawResponse
12982
+ );
12983
+ case 400:
12984
+ throw new Error2(
12985
+ _response.error.body,
12986
+ _response.rawResponse
12987
+ );
12988
+ case 401:
12989
+ throw new UnauthorizedError(
12990
+ _response.error.body,
12991
+ _response.rawResponse
12992
+ );
12993
+ case 403:
12994
+ throw new AccessDeniedError(
12995
+ _response.error.body,
12996
+ _response.rawResponse
12997
+ );
12998
+ case 405:
12999
+ throw new MethodNotAllowedError(
13000
+ _response.error.body,
13001
+ _response.rawResponse
13002
+ );
13003
+ case 404:
13004
+ throw new NotFoundError(
13005
+ _response.error.body,
13006
+ _response.rawResponse
13007
+ );
13008
+ default:
13009
+ throw new LangfuseAPIError({
13010
+ statusCode: _response.error.statusCode,
13011
+ body: _response.error.body,
13012
+ rawResponse: _response.rawResponse
13013
+ });
13014
+ }
13015
+ }
13016
+ switch (_response.error.reason) {
13017
+ case "non-json":
13018
+ throw new LangfuseAPIError({
13019
+ statusCode: _response.error.statusCode,
13020
+ body: _response.error.rawBody,
13021
+ rawResponse: _response.rawResponse
13022
+ });
13023
+ case "timeout":
13024
+ throw new LangfuseAPITimeoutError(
13025
+ "Timeout exceeded when calling GET /api/public/unstable/evaluation-rules/{evaluationRuleId}."
13026
+ );
13027
+ case "unknown":
13028
+ throw new LangfuseAPIError({
13029
+ message: _response.error.errorMessage,
13030
+ rawResponse: _response.rawResponse
13031
+ });
13032
+ }
13033
+ }
13034
+ /**
13035
+ * Update an evaluation rule.
13036
+ *
13037
+ * Typical uses:
13038
+ * - enable or disable live execution
13039
+ * - switch to another evaluator
13040
+ * - adjust sampling
13041
+ * - change filters
13042
+ * - update variable mappings
13043
+ *
13044
+ * Important behavior:
13045
+ * - provide only the fields you want to change
13046
+ * - if you provide `evaluator`, Langfuse resolves that evaluator family to its latest version before saving
13047
+ * - changing `target`, `filter`, or `mapping` must still produce a valid target-specific configuration
13048
+ * - if you change `target`, also send a compatible `filter` and `mapping` in the same request unless the existing ones are still valid for the new target
13049
+ * - if the resulting config is enabled, Langfuse re-validates that the selected evaluator can run
13050
+ * - if the update would move a non-active evaluation rule into the active state and the project already has 50 active evaluation rules, the API returns `409`
13051
+ *
13052
+ * Recovery guidance:
13053
+ * - if the update fails with `missing_variable_mapping` or `invalid_variable_mapping` after changing `evaluator` or `target`, resend the request with a complete new `mapping`
13054
+ * - if the update fails with `invalid_filter_value` after changing `target`, resend the request with a target-compatible `filter`
13055
+ *
13056
+ * @param {string} evaluationRuleId - Evaluation rule identifier.
13057
+ * @param {LangfuseAPI.unstable.UpdateEvaluationRuleRequest} request
13058
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
13059
+ *
13060
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13061
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13062
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13063
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
13064
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13065
+ * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
13066
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13067
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13068
+ * @throws {@link LangfuseAPI.Error}
13069
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13070
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13071
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13072
+ * @throws {@link LangfuseAPI.NotFoundError}
13073
+ *
13074
+ * @example
13075
+ * await client.unstable.evaluationRules.update("evaluationRuleId", {
13076
+ * name: undefined,
13077
+ * evaluator: undefined,
13078
+ * target: undefined,
13079
+ * enabled: undefined,
13080
+ * sampling: undefined,
13081
+ * filter: undefined,
13082
+ * mapping: undefined
13083
+ * })
13084
+ */
13085
+ update(evaluationRuleId, request, requestOptions) {
13086
+ return HttpResponsePromise.fromPromise(
13087
+ this.__update(evaluationRuleId, request, requestOptions)
13088
+ );
13089
+ }
13090
+ async __update(evaluationRuleId, request, requestOptions) {
13091
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13092
+ let _headers = mergeHeaders(
13093
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13094
+ mergeOnlyDefinedHeaders({
13095
+ Authorization: await this._getAuthorizationHeader(),
13096
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13097
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13098
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13099
+ }),
13100
+ requestOptions == null ? void 0 : requestOptions.headers
13101
+ );
13102
+ const _response = await fetcher({
13103
+ url: url_exports.join(
13104
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13105
+ `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
13106
+ ),
13107
+ method: "PATCH",
13108
+ headers: _headers,
13109
+ contentType: "application/json",
13110
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13111
+ requestType: "json",
13112
+ body: request,
13113
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13114
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13115
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13116
+ });
13117
+ if (_response.ok) {
13118
+ return {
13119
+ data: _response.body,
13120
+ rawResponse: _response.rawResponse
13121
+ };
13122
+ }
13123
+ if (_response.error.reason === "status-code") {
13124
+ switch (_response.error.statusCode) {
13125
+ case 400:
13126
+ throw new unstable_exports.BadRequestError(
13127
+ _response.error.body,
13128
+ _response.rawResponse
13129
+ );
13130
+ case 401:
13131
+ throw new unstable_exports.UnauthorizedError(
13132
+ _response.error.body,
13133
+ _response.rawResponse
13134
+ );
13135
+ case 403:
13136
+ throw new unstable_exports.AccessDeniedError(
13137
+ _response.error.body,
13138
+ _response.rawResponse
13139
+ );
13140
+ case 404:
13141
+ throw new unstable_exports.NotFoundError(
13142
+ _response.error.body,
13143
+ _response.rawResponse
13144
+ );
13145
+ case 405:
13146
+ throw new unstable_exports.MethodNotAllowedError(
13147
+ _response.error.body,
13148
+ _response.rawResponse
13149
+ );
13150
+ case 422:
13151
+ throw new unstable_exports.UnprocessableContentError(
13152
+ _response.error.body,
13153
+ _response.rawResponse
13154
+ );
13155
+ case 429:
13156
+ throw new unstable_exports.TooManyRequestsError(
13157
+ _response.error.body,
13158
+ _response.rawResponse
13159
+ );
13160
+ case 500:
13161
+ throw new unstable_exports.InternalServerError(
13162
+ _response.error.body,
13163
+ _response.rawResponse
13164
+ );
13165
+ case 400:
13166
+ throw new Error2(
13167
+ _response.error.body,
13168
+ _response.rawResponse
13169
+ );
13170
+ case 401:
13171
+ throw new UnauthorizedError(
13172
+ _response.error.body,
13173
+ _response.rawResponse
13174
+ );
13175
+ case 403:
13176
+ throw new AccessDeniedError(
13177
+ _response.error.body,
13178
+ _response.rawResponse
13179
+ );
13180
+ case 405:
13181
+ throw new MethodNotAllowedError(
13182
+ _response.error.body,
13183
+ _response.rawResponse
13184
+ );
13185
+ case 404:
13186
+ throw new NotFoundError(
13187
+ _response.error.body,
13188
+ _response.rawResponse
13189
+ );
13190
+ default:
13191
+ throw new LangfuseAPIError({
13192
+ statusCode: _response.error.statusCode,
13193
+ body: _response.error.body,
13194
+ rawResponse: _response.rawResponse
13195
+ });
13196
+ }
13197
+ }
13198
+ switch (_response.error.reason) {
13199
+ case "non-json":
13200
+ throw new LangfuseAPIError({
13201
+ statusCode: _response.error.statusCode,
13202
+ body: _response.error.rawBody,
13203
+ rawResponse: _response.rawResponse
13204
+ });
13205
+ case "timeout":
13206
+ throw new LangfuseAPITimeoutError(
13207
+ "Timeout exceeded when calling PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}."
13208
+ );
13209
+ case "unknown":
13210
+ throw new LangfuseAPIError({
13211
+ message: _response.error.errorMessage,
13212
+ rawResponse: _response.rawResponse
13213
+ });
13214
+ }
13215
+ }
13216
+ /**
13217
+ * Delete an evaluation rule.
13218
+ *
13219
+ * This removes the live-ingestion rule only. It does not delete the referenced evaluator.
13220
+ *
13221
+ * @param {string} evaluationRuleId - Evaluation rule identifier.
13222
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
13223
+ *
13224
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13225
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13226
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13227
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
13228
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13229
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13230
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13231
+ * @throws {@link LangfuseAPI.Error}
13232
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13233
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13234
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13235
+ * @throws {@link LangfuseAPI.NotFoundError}
13236
+ *
13237
+ * @example
13238
+ * await client.unstable.evaluationRules.delete("evaluationRuleId")
13239
+ */
13240
+ delete(evaluationRuleId, requestOptions) {
13241
+ return HttpResponsePromise.fromPromise(
13242
+ this.__delete(evaluationRuleId, requestOptions)
13243
+ );
13244
+ }
13245
+ async __delete(evaluationRuleId, requestOptions) {
13246
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13247
+ let _headers = mergeHeaders(
13248
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13249
+ mergeOnlyDefinedHeaders({
13250
+ Authorization: await this._getAuthorizationHeader(),
13251
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13252
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13253
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13254
+ }),
13255
+ requestOptions == null ? void 0 : requestOptions.headers
13256
+ );
13257
+ const _response = await fetcher({
13258
+ url: url_exports.join(
13259
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13260
+ `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
13261
+ ),
13262
+ method: "DELETE",
13263
+ headers: _headers,
13264
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13265
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13266
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13267
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13268
+ });
13269
+ if (_response.ok) {
13270
+ return {
13271
+ data: _response.body,
13272
+ rawResponse: _response.rawResponse
13273
+ };
13274
+ }
13275
+ if (_response.error.reason === "status-code") {
13276
+ switch (_response.error.statusCode) {
13277
+ case 400:
13278
+ throw new unstable_exports.BadRequestError(
13279
+ _response.error.body,
13280
+ _response.rawResponse
13281
+ );
13282
+ case 401:
13283
+ throw new unstable_exports.UnauthorizedError(
13284
+ _response.error.body,
13285
+ _response.rawResponse
13286
+ );
13287
+ case 403:
13288
+ throw new unstable_exports.AccessDeniedError(
13289
+ _response.error.body,
13290
+ _response.rawResponse
13291
+ );
13292
+ case 404:
13293
+ throw new unstable_exports.NotFoundError(
13294
+ _response.error.body,
13295
+ _response.rawResponse
13296
+ );
13297
+ case 405:
13298
+ throw new unstable_exports.MethodNotAllowedError(
13299
+ _response.error.body,
13300
+ _response.rawResponse
13301
+ );
13302
+ case 429:
13303
+ throw new unstable_exports.TooManyRequestsError(
13304
+ _response.error.body,
13305
+ _response.rawResponse
13306
+ );
13307
+ case 500:
13308
+ throw new unstable_exports.InternalServerError(
13309
+ _response.error.body,
13310
+ _response.rawResponse
13311
+ );
13312
+ case 400:
13313
+ throw new Error2(
13314
+ _response.error.body,
13315
+ _response.rawResponse
13316
+ );
13317
+ case 401:
13318
+ throw new UnauthorizedError(
13319
+ _response.error.body,
13320
+ _response.rawResponse
13321
+ );
13322
+ case 403:
13323
+ throw new AccessDeniedError(
13324
+ _response.error.body,
13325
+ _response.rawResponse
13326
+ );
13327
+ case 405:
13328
+ throw new MethodNotAllowedError(
13329
+ _response.error.body,
13330
+ _response.rawResponse
13331
+ );
13332
+ case 404:
13333
+ throw new NotFoundError(
13334
+ _response.error.body,
13335
+ _response.rawResponse
13336
+ );
13337
+ default:
13338
+ throw new LangfuseAPIError({
13339
+ statusCode: _response.error.statusCode,
13340
+ body: _response.error.body,
13341
+ rawResponse: _response.rawResponse
13342
+ });
13343
+ }
13344
+ }
13345
+ switch (_response.error.reason) {
13346
+ case "non-json":
13347
+ throw new LangfuseAPIError({
13348
+ statusCode: _response.error.statusCode,
13349
+ body: _response.error.rawBody,
13350
+ rawResponse: _response.rawResponse
13351
+ });
13352
+ case "timeout":
13353
+ throw new LangfuseAPITimeoutError(
13354
+ "Timeout exceeded when calling DELETE /api/public/unstable/evaluation-rules/{evaluationRuleId}."
13355
+ );
13356
+ case "unknown":
13357
+ throw new LangfuseAPIError({
13358
+ message: _response.error.errorMessage,
13359
+ rawResponse: _response.rawResponse
13360
+ });
13361
+ }
13362
+ }
13363
+ async _getAuthorizationHeader() {
13364
+ const username = await Supplier.get(this._options.username);
13365
+ const password = await Supplier.get(this._options.password);
13366
+ if (username != null && password != null) {
13367
+ return BasicAuth.toAuthorizationHeader({
13368
+ username,
13369
+ password
13370
+ });
13371
+ }
13372
+ return void 0;
13373
+ }
13374
+ };
13375
+
13376
+ // src/api/api/resources/unstable/resources/evaluators/client/Client.ts
13377
+ var Evaluators = class {
13378
+ constructor(_options) {
13379
+ this._options = _options;
13380
+ }
13381
+ /**
13382
+ * Create an evaluator in the authenticated project.
13383
+ *
13384
+ * Use evaluators to define **how** Langfuse should score data: the prompt, the expected structured output, and the optional model configuration.
13385
+ *
13386
+ * Naming behavior:
13387
+ * - If this is a new evaluator name in your project, Langfuse creates version `1`.
13388
+ * - If the name already exists in your project, Langfuse creates the next version and returns it.
13389
+ * - When a new project version is created, existing evaluation rules in that project automatically move to the newest version for that evaluator name.
13390
+ *
13391
+ * Recommended workflow:
13392
+ * 1. Create the evaluator.
13393
+ * 2. Read the returned `variables` array.
13394
+ * 3. Read the returned `outputDefinition.dataType` so the client knows whether future scores will be numeric, boolean, or categorical.
13395
+ * 4. Create one or more evaluation rules that reference the returned evaluator family using `name` and `scope`.
13396
+ *
13397
+ * Recovery guidance:
13398
+ * - `422` with `code=evaluator_preflight_failed`: the evaluator cannot run with the resolved model configuration. Add a valid explicit `modelConfig`, or configure the project's default evaluation model, then retry the same request.
13399
+ * - `400` with `code=invalid_body`: the request shape is malformed. Use the structured `details.issues` array to fix the specific fields and retry.
13400
+ * - `400` with `code=invalid_body` on `outputDefinition`: send `dataType`, `reasoning.description`, and `score.description`. Do not send `version`; it is not part of the public request shape.
13401
+ *
13402
+ * Unstable API note:
13403
+ * - This surface may evolve while the underlying evaluation data model is being redesigned.
13404
+ *
13405
+ * @param {LangfuseAPI.unstable.CreateEvaluatorRequest} request
13406
+ * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
13407
+ *
13408
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13409
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13410
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13411
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13412
+ * @throws {@link LangfuseAPI.unstable.ConflictError}
13413
+ * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
13414
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13415
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13416
+ * @throws {@link LangfuseAPI.Error}
13417
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13418
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13419
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13420
+ * @throws {@link LangfuseAPI.NotFoundError}
13421
+ *
13422
+ * @example
13423
+ * await client.unstable.evaluators.create({
13424
+ * name: "answer-correctness",
13425
+ * prompt: "You are grading an answer.\n\nInput:\n{{input}}\n\nOutput:\n{{output}}\n\nReturn a score between 0 and 1.\n",
13426
+ * outputDefinition: {
13427
+ * dataType: "NUMERIC",
13428
+ * dataType: "NUMERIC",
13429
+ * reasoning: {
13430
+ * description: "Explain why the score was assigned."
13431
+ * },
13432
+ * score: {
13433
+ * description: "Correctness score between 0 and 1."
13434
+ * }
13435
+ * },
13436
+ * modelConfig: {
13437
+ * provider: "openai",
13438
+ * model: "gpt-4.1-mini"
13439
+ * }
13440
+ * })
13441
+ */
13442
+ create(request, requestOptions) {
13443
+ return HttpResponsePromise.fromPromise(
13444
+ this.__create(request, requestOptions)
13445
+ );
13446
+ }
13447
+ async __create(request, requestOptions) {
13448
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13449
+ let _headers = mergeHeaders(
13450
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13451
+ mergeOnlyDefinedHeaders({
13452
+ Authorization: await this._getAuthorizationHeader(),
13453
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13454
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13455
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13456
+ }),
13457
+ requestOptions == null ? void 0 : requestOptions.headers
13458
+ );
13459
+ const _response = await fetcher({
13460
+ url: url_exports.join(
13461
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13462
+ "/api/public/unstable/evaluators"
13463
+ ),
13464
+ method: "POST",
13465
+ headers: _headers,
13466
+ contentType: "application/json",
13467
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13468
+ requestType: "json",
13469
+ body: request,
13470
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13471
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13472
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13473
+ });
13474
+ if (_response.ok) {
13475
+ return {
13476
+ data: _response.body,
13477
+ rawResponse: _response.rawResponse
13478
+ };
13479
+ }
13480
+ if (_response.error.reason === "status-code") {
13481
+ switch (_response.error.statusCode) {
13482
+ case 400:
13483
+ throw new unstable_exports.BadRequestError(
13484
+ _response.error.body,
13485
+ _response.rawResponse
13486
+ );
13487
+ case 401:
13488
+ throw new unstable_exports.UnauthorizedError(
13489
+ _response.error.body,
13490
+ _response.rawResponse
13491
+ );
13492
+ case 403:
13493
+ throw new unstable_exports.AccessDeniedError(
13494
+ _response.error.body,
13495
+ _response.rawResponse
13496
+ );
13497
+ case 405:
13498
+ throw new unstable_exports.MethodNotAllowedError(
13499
+ _response.error.body,
13500
+ _response.rawResponse
13501
+ );
13502
+ case 409:
13503
+ throw new unstable_exports.ConflictError(
13504
+ _response.error.body,
13505
+ _response.rawResponse
13506
+ );
13507
+ case 422:
13508
+ throw new unstable_exports.UnprocessableContentError(
13509
+ _response.error.body,
13510
+ _response.rawResponse
13511
+ );
13512
+ case 429:
13513
+ throw new unstable_exports.TooManyRequestsError(
13514
+ _response.error.body,
13515
+ _response.rawResponse
13516
+ );
13517
+ case 500:
13518
+ throw new unstable_exports.InternalServerError(
13519
+ _response.error.body,
13520
+ _response.rawResponse
13521
+ );
13522
+ case 400:
13523
+ throw new Error2(
13524
+ _response.error.body,
13525
+ _response.rawResponse
13526
+ );
13527
+ case 401:
13528
+ throw new UnauthorizedError(
13529
+ _response.error.body,
13530
+ _response.rawResponse
13531
+ );
13532
+ case 403:
13533
+ throw new AccessDeniedError(
13534
+ _response.error.body,
13535
+ _response.rawResponse
13536
+ );
13537
+ case 405:
13538
+ throw new MethodNotAllowedError(
13539
+ _response.error.body,
13540
+ _response.rawResponse
13541
+ );
13542
+ case 404:
13543
+ throw new NotFoundError(
13544
+ _response.error.body,
13545
+ _response.rawResponse
13546
+ );
13547
+ default:
13548
+ throw new LangfuseAPIError({
13549
+ statusCode: _response.error.statusCode,
13550
+ body: _response.error.body,
13551
+ rawResponse: _response.rawResponse
13552
+ });
13553
+ }
13554
+ }
13555
+ switch (_response.error.reason) {
13556
+ case "non-json":
13557
+ throw new LangfuseAPIError({
13558
+ statusCode: _response.error.statusCode,
13559
+ body: _response.error.rawBody,
13560
+ rawResponse: _response.rawResponse
13561
+ });
13562
+ case "timeout":
13563
+ throw new LangfuseAPITimeoutError(
13564
+ "Timeout exceeded when calling POST /api/public/unstable/evaluators."
13565
+ );
13566
+ case "unknown":
13567
+ throw new LangfuseAPIError({
13568
+ message: _response.error.errorMessage,
13569
+ rawResponse: _response.rawResponse
13570
+ });
13571
+ }
13572
+ }
13573
+ /**
13574
+ * List the evaluators available to the authenticated project.
13575
+ *
13576
+ * Important behavior:
13577
+ * - This endpoint returns the latest version of each available evaluator.
13578
+ * - Results can include evaluators from your project and Langfuse-managed evaluators.
13579
+ * - If the same evaluator name exists in both places, both are returned as separate items with different `scope` values.
13580
+ *
13581
+ * @param {LangfuseAPI.unstable.ListEvaluatorsRequest} request
13582
+ * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
13583
+ *
13584
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13585
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13586
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13587
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13588
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13589
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13590
+ * @throws {@link LangfuseAPI.Error}
13591
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13592
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13593
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13594
+ * @throws {@link LangfuseAPI.NotFoundError}
13595
+ *
13596
+ * @example
13597
+ * await client.unstable.evaluators.list()
13598
+ */
13599
+ list(request = {}, requestOptions) {
13600
+ return HttpResponsePromise.fromPromise(
13601
+ this.__list(request, requestOptions)
13602
+ );
13603
+ }
13604
+ async __list(request = {}, requestOptions) {
13605
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13606
+ const { page, limit } = request;
13607
+ const _queryParams = {};
13608
+ if (page != null) {
13609
+ _queryParams["page"] = page.toString();
13610
+ }
13611
+ if (limit != null) {
13612
+ _queryParams["limit"] = limit.toString();
13613
+ }
13614
+ let _headers = mergeHeaders(
13615
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13616
+ mergeOnlyDefinedHeaders({
13617
+ Authorization: await this._getAuthorizationHeader(),
13618
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13619
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13620
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13621
+ }),
13622
+ requestOptions == null ? void 0 : requestOptions.headers
13623
+ );
13624
+ const _response = await fetcher({
13625
+ url: url_exports.join(
13626
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13627
+ "/api/public/unstable/evaluators"
13628
+ ),
13629
+ method: "GET",
13630
+ headers: _headers,
13631
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
13632
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13633
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13634
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13635
+ });
13636
+ if (_response.ok) {
13637
+ return {
13638
+ data: _response.body,
13639
+ rawResponse: _response.rawResponse
13640
+ };
13641
+ }
13642
+ if (_response.error.reason === "status-code") {
13643
+ switch (_response.error.statusCode) {
13644
+ case 400:
13645
+ throw new unstable_exports.BadRequestError(
13646
+ _response.error.body,
13647
+ _response.rawResponse
13648
+ );
13649
+ case 401:
13650
+ throw new unstable_exports.UnauthorizedError(
13651
+ _response.error.body,
13652
+ _response.rawResponse
13653
+ );
13654
+ case 403:
13655
+ throw new unstable_exports.AccessDeniedError(
13656
+ _response.error.body,
13657
+ _response.rawResponse
13658
+ );
13659
+ case 405:
13660
+ throw new unstable_exports.MethodNotAllowedError(
13661
+ _response.error.body,
13662
+ _response.rawResponse
13663
+ );
13664
+ case 429:
13665
+ throw new unstable_exports.TooManyRequestsError(
13666
+ _response.error.body,
13667
+ _response.rawResponse
13668
+ );
13669
+ case 500:
13670
+ throw new unstable_exports.InternalServerError(
13671
+ _response.error.body,
13672
+ _response.rawResponse
13673
+ );
13674
+ case 400:
13675
+ throw new Error2(
13676
+ _response.error.body,
13677
+ _response.rawResponse
13678
+ );
13679
+ case 401:
13680
+ throw new UnauthorizedError(
13681
+ _response.error.body,
13682
+ _response.rawResponse
13683
+ );
13684
+ case 403:
13685
+ throw new AccessDeniedError(
13686
+ _response.error.body,
13687
+ _response.rawResponse
13688
+ );
13689
+ case 405:
13690
+ throw new MethodNotAllowedError(
13691
+ _response.error.body,
13692
+ _response.rawResponse
13693
+ );
13694
+ case 404:
13695
+ throw new NotFoundError(
13696
+ _response.error.body,
13697
+ _response.rawResponse
13698
+ );
13699
+ default:
13700
+ throw new LangfuseAPIError({
13701
+ statusCode: _response.error.statusCode,
13702
+ body: _response.error.body,
13703
+ rawResponse: _response.rawResponse
13704
+ });
13705
+ }
13706
+ }
13707
+ switch (_response.error.reason) {
13708
+ case "non-json":
13709
+ throw new LangfuseAPIError({
13710
+ statusCode: _response.error.statusCode,
13711
+ body: _response.error.rawBody,
13712
+ rawResponse: _response.rawResponse
13713
+ });
13714
+ case "timeout":
13715
+ throw new LangfuseAPITimeoutError(
13716
+ "Timeout exceeded when calling GET /api/public/unstable/evaluators."
13717
+ );
13718
+ case "unknown":
13719
+ throw new LangfuseAPIError({
13720
+ message: _response.error.errorMessage,
13721
+ rawResponse: _response.rawResponse
13722
+ });
13723
+ }
13724
+ }
13725
+ /**
13726
+ * Get one evaluator by `id`.
13727
+ *
13728
+ * Use this endpoint when you want the prompt, output definition, model configuration, and derived variables for the evaluator you plan to use in an evaluation rule.
13729
+ *
13730
+ * @param {string} evaluatorId - Evaluator identifier returned by the evaluator endpoints.
13731
+ * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
13732
+ *
13733
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13734
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13735
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13736
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
13737
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13738
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13739
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13740
+ * @throws {@link LangfuseAPI.Error}
13741
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13742
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13743
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13744
+ * @throws {@link LangfuseAPI.NotFoundError}
13745
+ *
13746
+ * @example
13747
+ * await client.unstable.evaluators.get("evaluatorId")
13748
+ */
13749
+ get(evaluatorId, requestOptions) {
13750
+ return HttpResponsePromise.fromPromise(
13751
+ this.__get(evaluatorId, requestOptions)
13752
+ );
13753
+ }
13754
+ async __get(evaluatorId, requestOptions) {
13755
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13756
+ let _headers = mergeHeaders(
13757
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13758
+ mergeOnlyDefinedHeaders({
13759
+ Authorization: await this._getAuthorizationHeader(),
13760
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13761
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13762
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13763
+ }),
13764
+ requestOptions == null ? void 0 : requestOptions.headers
13765
+ );
13766
+ const _response = await fetcher({
13767
+ url: url_exports.join(
13768
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13769
+ `/api/public/unstable/evaluators/${encodeURIComponent(evaluatorId)}`
13770
+ ),
13771
+ method: "GET",
13772
+ headers: _headers,
13773
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13774
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13775
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13776
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13777
+ });
13778
+ if (_response.ok) {
13779
+ return {
13780
+ data: _response.body,
13781
+ rawResponse: _response.rawResponse
13782
+ };
13783
+ }
13784
+ if (_response.error.reason === "status-code") {
13785
+ switch (_response.error.statusCode) {
13786
+ case 400:
13787
+ throw new unstable_exports.BadRequestError(
13788
+ _response.error.body,
13789
+ _response.rawResponse
13790
+ );
13791
+ case 401:
13792
+ throw new unstable_exports.UnauthorizedError(
13793
+ _response.error.body,
13794
+ _response.rawResponse
13795
+ );
13796
+ case 403:
13797
+ throw new unstable_exports.AccessDeniedError(
13798
+ _response.error.body,
13799
+ _response.rawResponse
13800
+ );
13801
+ case 404:
13802
+ throw new unstable_exports.NotFoundError(
13803
+ _response.error.body,
13804
+ _response.rawResponse
13805
+ );
13806
+ case 405:
13807
+ throw new unstable_exports.MethodNotAllowedError(
13808
+ _response.error.body,
13809
+ _response.rawResponse
13810
+ );
13811
+ case 429:
13812
+ throw new unstable_exports.TooManyRequestsError(
13813
+ _response.error.body,
13814
+ _response.rawResponse
13815
+ );
13816
+ case 500:
13817
+ throw new unstable_exports.InternalServerError(
13818
+ _response.error.body,
13819
+ _response.rawResponse
13820
+ );
13821
+ case 400:
13822
+ throw new Error2(
13823
+ _response.error.body,
13824
+ _response.rawResponse
13825
+ );
13826
+ case 401:
13827
+ throw new UnauthorizedError(
13828
+ _response.error.body,
13829
+ _response.rawResponse
13830
+ );
13831
+ case 403:
13832
+ throw new AccessDeniedError(
13833
+ _response.error.body,
13834
+ _response.rawResponse
13835
+ );
13836
+ case 405:
13837
+ throw new MethodNotAllowedError(
13838
+ _response.error.body,
13839
+ _response.rawResponse
13840
+ );
13841
+ case 404:
13842
+ throw new NotFoundError(
13843
+ _response.error.body,
13844
+ _response.rawResponse
13845
+ );
13846
+ default:
13847
+ throw new LangfuseAPIError({
13848
+ statusCode: _response.error.statusCode,
13849
+ body: _response.error.body,
13850
+ rawResponse: _response.rawResponse
13851
+ });
13852
+ }
13853
+ }
13854
+ switch (_response.error.reason) {
13855
+ case "non-json":
13856
+ throw new LangfuseAPIError({
13857
+ statusCode: _response.error.statusCode,
13858
+ body: _response.error.rawBody,
13859
+ rawResponse: _response.rawResponse
13860
+ });
13861
+ case "timeout":
13862
+ throw new LangfuseAPITimeoutError(
13863
+ "Timeout exceeded when calling GET /api/public/unstable/evaluators/{evaluatorId}."
13864
+ );
13865
+ case "unknown":
13866
+ throw new LangfuseAPIError({
13867
+ message: _response.error.errorMessage,
13868
+ rawResponse: _response.rawResponse
13869
+ });
13870
+ }
13871
+ }
13872
+ async _getAuthorizationHeader() {
13873
+ const username = await Supplier.get(this._options.username);
13874
+ const password = await Supplier.get(this._options.password);
13875
+ if (username != null && password != null) {
13876
+ return BasicAuth.toAuthorizationHeader({
13877
+ username,
13878
+ password
13879
+ });
13880
+ }
13881
+ return void 0;
13882
+ }
13883
+ };
13884
+
13885
+ // src/api/api/resources/unstable/client/Client.ts
13886
+ var Unstable = class {
13887
+ constructor(_options) {
13888
+ this._options = _options;
13889
+ }
13890
+ get evaluationRules() {
13891
+ var _a2;
13892
+ return (_a2 = this._evaluationRules) != null ? _a2 : this._evaluationRules = new EvaluationRules(this._options);
13893
+ }
13894
+ get evaluators() {
13895
+ var _a2;
13896
+ return (_a2 = this._evaluators) != null ? _a2 : this._evaluators = new Evaluators(this._options);
13897
+ }
13898
+ };
13899
+
13900
+ // src/api/Client.ts
13901
+ var LangfuseAPIClient = class {
13902
+ constructor(_options) {
13903
+ this._options = {
13904
+ ..._options,
13905
+ headers: mergeHeaders(
13906
+ {
13907
+ "X-Langfuse-Sdk-Name": _options == null ? void 0 : _options.xLangfuseSdkName,
13908
+ "X-Langfuse-Sdk-Version": _options == null ? void 0 : _options.xLangfuseSdkVersion,
13909
+ "X-Langfuse-Public-Key": _options == null ? void 0 : _options.xLangfusePublicKey
13910
+ },
13911
+ _options == null ? void 0 : _options.headers
13912
+ )
13913
+ };
13914
+ }
13915
+ get annotationQueues() {
13916
+ var _a2;
13917
+ return (_a2 = this._annotationQueues) != null ? _a2 : this._annotationQueues = new AnnotationQueues(this._options);
13918
+ }
13919
+ get blobStorageIntegrations() {
13920
+ var _a2;
13921
+ return (_a2 = this._blobStorageIntegrations) != null ? _a2 : this._blobStorageIntegrations = new BlobStorageIntegrations(
13922
+ this._options
13923
+ );
13924
+ }
13925
+ get comments() {
13926
+ var _a2;
13927
+ return (_a2 = this._comments) != null ? _a2 : this._comments = new Comments(this._options);
12087
13928
  }
12088
13929
  get datasetItems() {
12089
13930
  var _a2;
@@ -12169,6 +14010,10 @@ var LangfuseAPIClient = class {
12169
14010
  var _a2;
12170
14011
  return (_a2 = this._trace) != null ? _a2 : this._trace = new Trace(this._options);
12171
14012
  }
14013
+ get unstable() {
14014
+ var _a2;
14015
+ return (_a2 = this._unstable) != null ? _a2 : this._unstable = new Unstable(this._options);
14016
+ }
12172
14017
  };
12173
14018
 
12174
14019
  // src/media.ts
@@ -12756,8 +14601,10 @@ export {
12756
14601
  AccessDeniedError,
12757
14602
  AnnotationQueueObjectType,
12758
14603
  AnnotationQueueStatus,
14604
+ BlobStorageExportFieldGroup,
12759
14605
  BlobStorageExportFrequency,
12760
14606
  BlobStorageExportMode,
14607
+ BlobStorageExportSource,
12761
14608
  BlobStorageIntegrationFileType,
12762
14609
  BlobStorageIntegrationType,
12763
14610
  BlobStorageSyncStatus,
@@ -12840,6 +14687,7 @@ export {
12840
14687
  sessions_exports as sessions,
12841
14688
  setLangfuseTraceIdInBaggage,
12842
14689
  trace_exports as trace,
14690
+ unstable_exports as unstable,
12843
14691
  utils_exports as utils
12844
14692
  };
12845
14693
  //# sourceMappingURL=index.mjs.map