@langfuse/core 5.4.0 → 5.5.0-beta.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
@@ -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.5.0-beta.0",
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 = {};
@@ -843,6 +878,9 @@ var scim_exports = {};
843
878
  // src/api/api/resources/scoreConfigs/index.ts
844
879
  var scoreConfigs_exports = {};
845
880
 
881
+ // src/api/api/resources/scoresV3/index.ts
882
+ var scoresV3_exports = {};
883
+
846
884
  // src/api/api/resources/scores/index.ts
847
885
  var scores_exports = {};
848
886
 
@@ -852,6 +890,315 @@ var sessions_exports = {};
852
890
  // src/api/api/resources/trace/index.ts
853
891
  var trace_exports = {};
854
892
 
893
+ // src/api/api/resources/unstable/index.ts
894
+ var unstable_exports = {};
895
+ __export(unstable_exports, {
896
+ AccessDeniedError: () => AccessDeniedError2,
897
+ BadRequestError: () => BadRequestError,
898
+ CodeEvaluatorSourceCodeLanguage: () => CodeEvaluatorSourceCodeLanguage,
899
+ ConflictError: () => ConflictError,
900
+ EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator,
901
+ EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator,
902
+ EvaluationRuleMappingSource: () => EvaluationRuleMappingSource,
903
+ EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator,
904
+ EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator,
905
+ EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator,
906
+ EvaluationRuleStatus: () => EvaluationRuleStatus,
907
+ EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator,
908
+ EvaluationRuleTarget: () => EvaluationRuleTarget,
909
+ EvaluatorOutputDataType: () => EvaluatorOutputDataType,
910
+ EvaluatorScope: () => EvaluatorScope,
911
+ EvaluatorType: () => EvaluatorType,
912
+ InternalServerError: () => InternalServerError,
913
+ LlmAsJudgeEvaluatorType: () => LlmAsJudgeEvaluatorType,
914
+ MethodNotAllowedError: () => MethodNotAllowedError2,
915
+ NotFoundError: () => NotFoundError2,
916
+ PublicApiErrorCode: () => PublicApiErrorCode,
917
+ TooManyRequestsError: () => TooManyRequestsError,
918
+ UnauthorizedError: () => UnauthorizedError2,
919
+ UnprocessableContentError: () => UnprocessableContentError,
920
+ commons: () => commons_exports2,
921
+ errors: () => errors_exports2,
922
+ evaluationRules: () => evaluationRules_exports,
923
+ evaluators: () => evaluators_exports
924
+ });
925
+
926
+ // src/api/api/resources/unstable/resources/commons/index.ts
927
+ var commons_exports2 = {};
928
+ __export(commons_exports2, {
929
+ CodeEvaluatorSourceCodeLanguage: () => CodeEvaluatorSourceCodeLanguage,
930
+ EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator,
931
+ EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator,
932
+ EvaluationRuleMappingSource: () => EvaluationRuleMappingSource,
933
+ EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator,
934
+ EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator,
935
+ EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator,
936
+ EvaluationRuleStatus: () => EvaluationRuleStatus,
937
+ EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator,
938
+ EvaluationRuleTarget: () => EvaluationRuleTarget,
939
+ EvaluatorOutputDataType: () => EvaluatorOutputDataType,
940
+ EvaluatorScope: () => EvaluatorScope,
941
+ EvaluatorType: () => EvaluatorType
942
+ });
943
+
944
+ // src/api/api/resources/unstable/resources/commons/types/EvaluatorType.ts
945
+ var EvaluatorType = {
946
+ LlmAsJudge: "llm_as_judge",
947
+ Code: "code"
948
+ };
949
+
950
+ // src/api/api/resources/unstable/resources/commons/types/CodeEvaluatorSourceCodeLanguage.ts
951
+ var CodeEvaluatorSourceCodeLanguage = {
952
+ Python: "PYTHON",
953
+ Typescript: "TYPESCRIPT"
954
+ };
955
+
956
+ // src/api/api/resources/unstable/resources/commons/types/EvaluatorScope.ts
957
+ var EvaluatorScope = {
958
+ Project: "project",
959
+ Managed: "managed"
960
+ };
961
+
962
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleTarget.ts
963
+ var EvaluationRuleTarget = {
964
+ Observation: "observation",
965
+ Experiment: "experiment"
966
+ };
967
+
968
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStatus.ts
969
+ var EvaluationRuleStatus = {
970
+ Active: "active",
971
+ Inactive: "inactive",
972
+ Paused: "paused"
973
+ };
974
+
975
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleMappingSource.ts
976
+ var EvaluationRuleMappingSource = {
977
+ Input: "input",
978
+ Output: "output",
979
+ Metadata: "metadata",
980
+ ExpectedOutput: "expected_output",
981
+ ExperimentItemMetadata: "experiment_item_metadata"
982
+ };
983
+
984
+ // src/api/api/resources/unstable/resources/commons/types/EvaluatorOutputDataType.ts
985
+ var EvaluatorOutputDataType = {
986
+ Numeric: "NUMERIC",
987
+ Boolean: "BOOLEAN",
988
+ Categorical: "CATEGORICAL"
989
+ };
990
+
991
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStringFilterOperator.ts
992
+ var EvaluationRuleStringFilterOperator = {
993
+ Equals: "=",
994
+ Contains: "contains",
995
+ DoesNotContain: "does not contain",
996
+ StartsWith: "starts with",
997
+ EndsWith: "ends with"
998
+ };
999
+
1000
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNumberFilterOperator.ts
1001
+ var EvaluationRuleNumberFilterOperator = {
1002
+ Equals: "=",
1003
+ GreaterThan: ">",
1004
+ LessThan: "<",
1005
+ GreaterThanOrEqual: ">=",
1006
+ LessThanOrEqual: "<="
1007
+ };
1008
+
1009
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleOptionsFilterOperator.ts
1010
+ var EvaluationRuleOptionsFilterOperator = {
1011
+ AnyOf: "any of",
1012
+ NoneOf: "none of"
1013
+ };
1014
+
1015
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleArrayOptionsFilterOperator.ts
1016
+ var EvaluationRuleArrayOptionsFilterOperator = {
1017
+ AnyOf: "any of",
1018
+ NoneOf: "none of",
1019
+ AllOf: "all of"
1020
+ };
1021
+
1022
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleBooleanFilterOperator.ts
1023
+ var EvaluationRuleBooleanFilterOperator = {
1024
+ Equals: "=",
1025
+ NotEquals: "<>"
1026
+ };
1027
+
1028
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNullFilterOperator.ts
1029
+ var EvaluationRuleNullFilterOperator = {
1030
+ IsNull: "is null",
1031
+ IsNotNull: "is not null"
1032
+ };
1033
+
1034
+ // src/api/api/resources/unstable/resources/errors/index.ts
1035
+ var errors_exports2 = {};
1036
+ __export(errors_exports2, {
1037
+ AccessDeniedError: () => AccessDeniedError2,
1038
+ BadRequestError: () => BadRequestError,
1039
+ ConflictError: () => ConflictError,
1040
+ InternalServerError: () => InternalServerError,
1041
+ MethodNotAllowedError: () => MethodNotAllowedError2,
1042
+ NotFoundError: () => NotFoundError2,
1043
+ PublicApiErrorCode: () => PublicApiErrorCode,
1044
+ TooManyRequestsError: () => TooManyRequestsError,
1045
+ UnauthorizedError: () => UnauthorizedError2,
1046
+ UnprocessableContentError: () => UnprocessableContentError
1047
+ });
1048
+
1049
+ // src/api/api/resources/unstable/resources/errors/types/PublicApiErrorCode.ts
1050
+ var PublicApiErrorCode = {
1051
+ AuthenticationFailed: "authentication_failed",
1052
+ AccessDenied: "access_denied",
1053
+ InvalidRequest: "invalid_request",
1054
+ InvalidQuery: "invalid_query",
1055
+ InvalidBody: "invalid_body",
1056
+ InvalidFilterValue: "invalid_filter_value",
1057
+ InvalidJsonPath: "invalid_json_path",
1058
+ InvalidVariableMapping: "invalid_variable_mapping",
1059
+ MissingVariableMapping: "missing_variable_mapping",
1060
+ DuplicateVariableMapping: "duplicate_variable_mapping",
1061
+ ResourceNotFound: "resource_not_found",
1062
+ NameConflict: "name_conflict",
1063
+ EvaluatorPreflightFailed: "evaluator_preflight_failed",
1064
+ Conflict: "conflict",
1065
+ UnprocessableContent: "unprocessable_content",
1066
+ RateLimited: "rate_limited",
1067
+ MethodNotAllowed: "method_not_allowed",
1068
+ InternalError: "internal_error"
1069
+ };
1070
+
1071
+ // src/api/api/resources/unstable/resources/errors/errors/BadRequestError.ts
1072
+ var BadRequestError = class _BadRequestError extends LangfuseAPIError {
1073
+ constructor(body, rawResponse) {
1074
+ super({
1075
+ message: "BadRequestError",
1076
+ statusCode: 400,
1077
+ body,
1078
+ rawResponse
1079
+ });
1080
+ Object.setPrototypeOf(this, _BadRequestError.prototype);
1081
+ }
1082
+ };
1083
+
1084
+ // src/api/api/resources/unstable/resources/errors/errors/UnauthorizedError.ts
1085
+ var UnauthorizedError2 = class _UnauthorizedError extends LangfuseAPIError {
1086
+ constructor(body, rawResponse) {
1087
+ super({
1088
+ message: "UnauthorizedError",
1089
+ statusCode: 401,
1090
+ body,
1091
+ rawResponse
1092
+ });
1093
+ Object.setPrototypeOf(this, _UnauthorizedError.prototype);
1094
+ }
1095
+ };
1096
+
1097
+ // src/api/api/resources/unstable/resources/errors/errors/AccessDeniedError.ts
1098
+ var AccessDeniedError2 = class _AccessDeniedError extends LangfuseAPIError {
1099
+ constructor(body, rawResponse) {
1100
+ super({
1101
+ message: "AccessDeniedError",
1102
+ statusCode: 403,
1103
+ body,
1104
+ rawResponse
1105
+ });
1106
+ Object.setPrototypeOf(this, _AccessDeniedError.prototype);
1107
+ }
1108
+ };
1109
+
1110
+ // src/api/api/resources/unstable/resources/errors/errors/NotFoundError.ts
1111
+ var NotFoundError2 = class _NotFoundError extends LangfuseAPIError {
1112
+ constructor(body, rawResponse) {
1113
+ super({
1114
+ message: "NotFoundError",
1115
+ statusCode: 404,
1116
+ body,
1117
+ rawResponse
1118
+ });
1119
+ Object.setPrototypeOf(this, _NotFoundError.prototype);
1120
+ }
1121
+ };
1122
+
1123
+ // src/api/api/resources/unstable/resources/errors/errors/MethodNotAllowedError.ts
1124
+ var MethodNotAllowedError2 = class _MethodNotAllowedError extends LangfuseAPIError {
1125
+ constructor(body, rawResponse) {
1126
+ super({
1127
+ message: "MethodNotAllowedError",
1128
+ statusCode: 405,
1129
+ body,
1130
+ rawResponse
1131
+ });
1132
+ Object.setPrototypeOf(this, _MethodNotAllowedError.prototype);
1133
+ }
1134
+ };
1135
+
1136
+ // src/api/api/resources/unstable/resources/errors/errors/ConflictError.ts
1137
+ var ConflictError = class _ConflictError extends LangfuseAPIError {
1138
+ constructor(body, rawResponse) {
1139
+ super({
1140
+ message: "ConflictError",
1141
+ statusCode: 409,
1142
+ body,
1143
+ rawResponse
1144
+ });
1145
+ Object.setPrototypeOf(this, _ConflictError.prototype);
1146
+ }
1147
+ };
1148
+
1149
+ // src/api/api/resources/unstable/resources/errors/errors/UnprocessableContentError.ts
1150
+ var UnprocessableContentError = class _UnprocessableContentError extends LangfuseAPIError {
1151
+ constructor(body, rawResponse) {
1152
+ super({
1153
+ message: "UnprocessableContentError",
1154
+ statusCode: 422,
1155
+ body,
1156
+ rawResponse
1157
+ });
1158
+ Object.setPrototypeOf(this, _UnprocessableContentError.prototype);
1159
+ }
1160
+ };
1161
+
1162
+ // src/api/api/resources/unstable/resources/errors/errors/TooManyRequestsError.ts
1163
+ var TooManyRequestsError = class _TooManyRequestsError extends LangfuseAPIError {
1164
+ constructor(body, rawResponse) {
1165
+ super({
1166
+ message: "TooManyRequestsError",
1167
+ statusCode: 429,
1168
+ body,
1169
+ rawResponse
1170
+ });
1171
+ Object.setPrototypeOf(this, _TooManyRequestsError.prototype);
1172
+ }
1173
+ };
1174
+
1175
+ // src/api/api/resources/unstable/resources/errors/errors/InternalServerError.ts
1176
+ var InternalServerError = class _InternalServerError extends LangfuseAPIError {
1177
+ constructor(body, rawResponse) {
1178
+ super({
1179
+ message: "InternalServerError",
1180
+ statusCode: 500,
1181
+ body,
1182
+ rawResponse
1183
+ });
1184
+ Object.setPrototypeOf(this, _InternalServerError.prototype);
1185
+ }
1186
+ };
1187
+
1188
+ // src/api/api/resources/unstable/resources/evaluationRules/index.ts
1189
+ var evaluationRules_exports = {};
1190
+ __export(evaluationRules_exports, {
1191
+ LlmAsJudgeEvaluatorType: () => LlmAsJudgeEvaluatorType
1192
+ });
1193
+
1194
+ // src/api/api/resources/unstable/resources/evaluationRules/types/LlmAsJudgeEvaluatorType.ts
1195
+ var LlmAsJudgeEvaluatorType = {
1196
+ LlmAsJudge: "llm_as_judge"
1197
+ };
1198
+
1199
+ // src/api/api/resources/unstable/resources/evaluators/index.ts
1200
+ var evaluators_exports = {};
1201
+
855
1202
  // src/api/api/resources/utils/index.ts
856
1203
  var utils_exports = {};
857
1204
  __export(utils_exports, {
@@ -2837,13 +3184,15 @@ var BlobStorageIntegrations = class {
2837
3184
  * accessKeyId: undefined,
2838
3185
  * secretAccessKey: undefined,
2839
3186
  * prefix: undefined,
2840
- * exportFrequency: "hourly",
3187
+ * exportFrequency: "every_20_minutes",
2841
3188
  * enabled: true,
2842
3189
  * forcePathStyle: true,
2843
3190
  * fileType: "JSON",
2844
3191
  * exportMode: "FULL_HISTORY",
2845
3192
  * exportStartDate: undefined,
2846
- * compressed: undefined
3193
+ * compressed: undefined,
3194
+ * exportSource: undefined,
3195
+ * exportFieldGroups: undefined
2847
3196
  * })
2848
3197
  */
2849
3198
  upsertBlobStorageIntegration(request, requestOptions) {
@@ -5647,7 +5996,8 @@ var ScoreV1 = class {
5647
5996
  * environment: undefined,
5648
5997
  * queueId: undefined,
5649
5998
  * dataType: undefined,
5650
- * configId: undefined
5999
+ * configId: undefined,
6000
+ * source: undefined
5651
6001
  * })
5652
6002
  */
5653
6003
  create(request, requestOptions) {
@@ -6104,6 +6454,109 @@ var LlmConnections = class {
6104
6454
  });
6105
6455
  }
6106
6456
  }
6457
+ /**
6458
+ * Delete an LLM connection by id. Evaluators that depend on the deleted connection are automatically paused.
6459
+ *
6460
+ * @param {string} id
6461
+ * @param {LlmConnections.RequestOptions} requestOptions - Request-specific configuration.
6462
+ *
6463
+ * @throws {@link LangfuseAPI.Error}
6464
+ * @throws {@link LangfuseAPI.UnauthorizedError}
6465
+ * @throws {@link LangfuseAPI.AccessDeniedError}
6466
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
6467
+ * @throws {@link LangfuseAPI.NotFoundError}
6468
+ *
6469
+ * @example
6470
+ * await client.llmConnections.delete("id")
6471
+ */
6472
+ delete(id, requestOptions) {
6473
+ return HttpResponsePromise.fromPromise(
6474
+ this.__delete(id, requestOptions)
6475
+ );
6476
+ }
6477
+ async __delete(id, requestOptions) {
6478
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
6479
+ let _headers = mergeHeaders(
6480
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
6481
+ mergeOnlyDefinedHeaders({
6482
+ Authorization: await this._getAuthorizationHeader(),
6483
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
6484
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
6485
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
6486
+ }),
6487
+ requestOptions == null ? void 0 : requestOptions.headers
6488
+ );
6489
+ const _response = await fetcher({
6490
+ url: url_exports.join(
6491
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
6492
+ `/api/public/llm-connections/${encodeURIComponent(id)}`
6493
+ ),
6494
+ method: "DELETE",
6495
+ headers: _headers,
6496
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
6497
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
6498
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
6499
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
6500
+ });
6501
+ if (_response.ok) {
6502
+ return {
6503
+ data: _response.body,
6504
+ rawResponse: _response.rawResponse
6505
+ };
6506
+ }
6507
+ if (_response.error.reason === "status-code") {
6508
+ switch (_response.error.statusCode) {
6509
+ case 400:
6510
+ throw new Error2(
6511
+ _response.error.body,
6512
+ _response.rawResponse
6513
+ );
6514
+ case 401:
6515
+ throw new UnauthorizedError(
6516
+ _response.error.body,
6517
+ _response.rawResponse
6518
+ );
6519
+ case 403:
6520
+ throw new AccessDeniedError(
6521
+ _response.error.body,
6522
+ _response.rawResponse
6523
+ );
6524
+ case 405:
6525
+ throw new MethodNotAllowedError(
6526
+ _response.error.body,
6527
+ _response.rawResponse
6528
+ );
6529
+ case 404:
6530
+ throw new NotFoundError(
6531
+ _response.error.body,
6532
+ _response.rawResponse
6533
+ );
6534
+ default:
6535
+ throw new LangfuseAPIError({
6536
+ statusCode: _response.error.statusCode,
6537
+ body: _response.error.body,
6538
+ rawResponse: _response.rawResponse
6539
+ });
6540
+ }
6541
+ }
6542
+ switch (_response.error.reason) {
6543
+ case "non-json":
6544
+ throw new LangfuseAPIError({
6545
+ statusCode: _response.error.statusCode,
6546
+ body: _response.error.rawBody,
6547
+ rawResponse: _response.rawResponse
6548
+ });
6549
+ case "timeout":
6550
+ throw new LangfuseAPITimeoutError(
6551
+ "Timeout exceeded when calling DELETE /api/public/llm-connections/{id}."
6552
+ );
6553
+ case "unknown":
6554
+ throw new LangfuseAPIError({
6555
+ message: _response.error.errorMessage,
6556
+ rawResponse: _response.rawResponse
6557
+ });
6558
+ }
6559
+ }
6107
6560
  async _getAuthorizationHeader() {
6108
6561
  const username = await Supplier.get(this._options.username);
6109
6562
  const password = await Supplier.get(this._options.password);
@@ -7154,9 +7607,10 @@ var Observations = class {
7154
7607
  * - `io` - input, output
7155
7608
  * - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
7156
7609
  * - `model` - providedModelName, internalModelId, modelParameters
7157
- * - `usage` - usageDetails, costDetails, totalCost
7610
+ * - `usage` - usageDetails, costDetails, totalCost, usagePricingTierName
7158
7611
  * - `prompt` - promptId, promptName, promptVersion
7159
7612
  * - `metrics` - latency, timeToFirstToken
7613
+ * - `trace_context` - tags, release, traceName
7160
7614
  *
7161
7615
  * If not specified, `core` and `basic` field groups are returned.
7162
7616
  *
@@ -10984,16 +11438,26 @@ var ScoreConfigs = class {
10984
11438
  }
10985
11439
  };
10986
11440
 
10987
- // src/api/api/resources/scores/client/Client.ts
10988
- var Scores = class {
11441
+ // src/api/api/resources/scoresV3/client/Client.ts
11442
+ var ScoresV3 = class {
10989
11443
  constructor(_options) {
10990
11444
  this._options = _options;
10991
11445
  }
10992
11446
  /**
10993
- * Get a list of scores (supports both trace and session scores)
11447
+ * Get a list of scores with a polymorphic `value` field (v3).
10994
11448
  *
10995
- * @param {LangfuseAPI.GetScoresRequest} request
10996
- * @param {Scores.RequestOptions} requestOptions - Request-specific configuration.
11449
+ * This endpoint requires Langfuse v4 or later.
11450
+ *
11451
+ * The `value` field type depends on `dataType`:
11452
+ * - `NUMERIC` → number
11453
+ * - `BOOLEAN` → boolean
11454
+ * - `CATEGORICAL`, `TEXT`, `CORRECTION` → string
11455
+ *
11456
+ * Use the `fields` parameter to include optional field groups beyond the
11457
+ * default `core`. Unknown group names return HTTP 400.
11458
+ *
11459
+ * @param {LangfuseAPI.GetScoresV3Request} request
11460
+ * @param {ScoresV3.RequestOptions} requestOptions - Request-specific configuration.
10997
11461
  *
10998
11462
  * @throws {@link LangfuseAPI.Error}
10999
11463
  * @throws {@link LangfuseAPI.UnauthorizedError}
@@ -11002,27 +11466,231 @@ var Scores = class {
11002
11466
  * @throws {@link LangfuseAPI.NotFoundError}
11003
11467
  *
11004
11468
  * @example
11005
- * await client.scores.getMany()
11469
+ * await client.scoresV3.getManyV3()
11006
11470
  */
11007
- getMany(request = {}, requestOptions) {
11471
+ getManyV3(request = {}, requestOptions) {
11008
11472
  return HttpResponsePromise.fromPromise(
11009
- this.__getMany(request, requestOptions)
11473
+ this.__getManyV3(request, requestOptions)
11010
11474
  );
11011
11475
  }
11012
- async __getMany(request = {}, requestOptions) {
11476
+ async __getManyV3(request = {}, requestOptions) {
11013
11477
  var _a2, _b, _c, _d, _e, _f, _g, _h;
11014
11478
  const {
11015
- page,
11016
11479
  limit,
11017
- userId,
11480
+ cursor,
11481
+ fields,
11482
+ id,
11018
11483
  name,
11019
- fromTimestamp,
11020
- toTimestamp,
11021
- environment,
11022
11484
  source,
11023
- operator,
11024
- value,
11025
- scoreIds,
11485
+ dataType,
11486
+ environment,
11487
+ configId,
11488
+ queueId,
11489
+ authorUserId,
11490
+ value,
11491
+ valueMin,
11492
+ valueMax,
11493
+ traceId,
11494
+ sessionId,
11495
+ observationId,
11496
+ experimentId,
11497
+ fromTimestamp,
11498
+ toTimestamp
11499
+ } = request;
11500
+ const _queryParams = {};
11501
+ if (limit != null) {
11502
+ _queryParams["limit"] = limit.toString();
11503
+ }
11504
+ if (cursor != null) {
11505
+ _queryParams["cursor"] = cursor;
11506
+ }
11507
+ if (fields != null) {
11508
+ _queryParams["fields"] = fields;
11509
+ }
11510
+ if (id != null) {
11511
+ _queryParams["id"] = id;
11512
+ }
11513
+ if (name != null) {
11514
+ _queryParams["name"] = name;
11515
+ }
11516
+ if (source != null) {
11517
+ _queryParams["source"] = source;
11518
+ }
11519
+ if (dataType != null) {
11520
+ _queryParams["dataType"] = dataType;
11521
+ }
11522
+ if (environment != null) {
11523
+ _queryParams["environment"] = environment;
11524
+ }
11525
+ if (configId != null) {
11526
+ _queryParams["configId"] = configId;
11527
+ }
11528
+ if (queueId != null) {
11529
+ _queryParams["queueId"] = queueId;
11530
+ }
11531
+ if (authorUserId != null) {
11532
+ _queryParams["authorUserId"] = authorUserId;
11533
+ }
11534
+ if (value != null) {
11535
+ _queryParams["value"] = value;
11536
+ }
11537
+ if (valueMin != null) {
11538
+ _queryParams["valueMin"] = valueMin.toString();
11539
+ }
11540
+ if (valueMax != null) {
11541
+ _queryParams["valueMax"] = valueMax.toString();
11542
+ }
11543
+ if (traceId != null) {
11544
+ _queryParams["traceId"] = traceId;
11545
+ }
11546
+ if (sessionId != null) {
11547
+ _queryParams["sessionId"] = sessionId;
11548
+ }
11549
+ if (observationId != null) {
11550
+ _queryParams["observationId"] = observationId;
11551
+ }
11552
+ if (experimentId != null) {
11553
+ _queryParams["experimentId"] = experimentId;
11554
+ }
11555
+ if (fromTimestamp != null) {
11556
+ _queryParams["fromTimestamp"] = fromTimestamp;
11557
+ }
11558
+ if (toTimestamp != null) {
11559
+ _queryParams["toTimestamp"] = toTimestamp;
11560
+ }
11561
+ let _headers = mergeHeaders(
11562
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
11563
+ mergeOnlyDefinedHeaders({
11564
+ Authorization: await this._getAuthorizationHeader(),
11565
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
11566
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
11567
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
11568
+ }),
11569
+ requestOptions == null ? void 0 : requestOptions.headers
11570
+ );
11571
+ const _response = await fetcher({
11572
+ url: url_exports.join(
11573
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
11574
+ "/api/public/v3/scores"
11575
+ ),
11576
+ method: "GET",
11577
+ headers: _headers,
11578
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
11579
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
11580
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
11581
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
11582
+ });
11583
+ if (_response.ok) {
11584
+ return {
11585
+ data: _response.body,
11586
+ rawResponse: _response.rawResponse
11587
+ };
11588
+ }
11589
+ if (_response.error.reason === "status-code") {
11590
+ switch (_response.error.statusCode) {
11591
+ case 400:
11592
+ throw new Error2(
11593
+ _response.error.body,
11594
+ _response.rawResponse
11595
+ );
11596
+ case 401:
11597
+ throw new UnauthorizedError(
11598
+ _response.error.body,
11599
+ _response.rawResponse
11600
+ );
11601
+ case 403:
11602
+ throw new AccessDeniedError(
11603
+ _response.error.body,
11604
+ _response.rawResponse
11605
+ );
11606
+ case 405:
11607
+ throw new MethodNotAllowedError(
11608
+ _response.error.body,
11609
+ _response.rawResponse
11610
+ );
11611
+ case 404:
11612
+ throw new NotFoundError(
11613
+ _response.error.body,
11614
+ _response.rawResponse
11615
+ );
11616
+ default:
11617
+ throw new LangfuseAPIError({
11618
+ statusCode: _response.error.statusCode,
11619
+ body: _response.error.body,
11620
+ rawResponse: _response.rawResponse
11621
+ });
11622
+ }
11623
+ }
11624
+ switch (_response.error.reason) {
11625
+ case "non-json":
11626
+ throw new LangfuseAPIError({
11627
+ statusCode: _response.error.statusCode,
11628
+ body: _response.error.rawBody,
11629
+ rawResponse: _response.rawResponse
11630
+ });
11631
+ case "timeout":
11632
+ throw new LangfuseAPITimeoutError(
11633
+ "Timeout exceeded when calling GET /api/public/v3/scores."
11634
+ );
11635
+ case "unknown":
11636
+ throw new LangfuseAPIError({
11637
+ message: _response.error.errorMessage,
11638
+ rawResponse: _response.rawResponse
11639
+ });
11640
+ }
11641
+ }
11642
+ async _getAuthorizationHeader() {
11643
+ const username = await Supplier.get(this._options.username);
11644
+ const password = await Supplier.get(this._options.password);
11645
+ if (username != null && password != null) {
11646
+ return BasicAuth.toAuthorizationHeader({
11647
+ username,
11648
+ password
11649
+ });
11650
+ }
11651
+ return void 0;
11652
+ }
11653
+ };
11654
+
11655
+ // src/api/api/resources/scores/client/Client.ts
11656
+ var Scores = class {
11657
+ constructor(_options) {
11658
+ this._options = _options;
11659
+ }
11660
+ /**
11661
+ * Get a list of scores (supports both trace and session scores)
11662
+ *
11663
+ * @param {LangfuseAPI.GetScoresRequest} request
11664
+ * @param {Scores.RequestOptions} requestOptions - Request-specific configuration.
11665
+ *
11666
+ * @throws {@link LangfuseAPI.Error}
11667
+ * @throws {@link LangfuseAPI.UnauthorizedError}
11668
+ * @throws {@link LangfuseAPI.AccessDeniedError}
11669
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
11670
+ * @throws {@link LangfuseAPI.NotFoundError}
11671
+ *
11672
+ * @example
11673
+ * await client.scores.getMany()
11674
+ */
11675
+ getMany(request = {}, requestOptions) {
11676
+ return HttpResponsePromise.fromPromise(
11677
+ this.__getMany(request, requestOptions)
11678
+ );
11679
+ }
11680
+ async __getMany(request = {}, requestOptions) {
11681
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
11682
+ const {
11683
+ page,
11684
+ limit,
11685
+ userId,
11686
+ name,
11687
+ fromTimestamp,
11688
+ toTimestamp,
11689
+ environment,
11690
+ source,
11691
+ operator,
11692
+ value,
11693
+ scoreIds,
11026
11694
  configId,
11027
11695
  sessionId,
11028
11696
  datasetRunId,
@@ -12056,41 +12724,1496 @@ var Trace = class {
12056
12724
  }
12057
12725
  };
12058
12726
 
12059
- // src/api/Client.ts
12060
- var LangfuseAPIClient = class {
12727
+ // src/api/api/resources/unstable/resources/evaluationRules/client/Client.ts
12728
+ var EvaluationRules = class {
12061
12729
  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);
12730
+ this._options = _options;
12077
12731
  }
12078
- get blobStorageIntegrations() {
12079
- var _a2;
12080
- return (_a2 = this._blobStorageIntegrations) != null ? _a2 : this._blobStorageIntegrations = new BlobStorageIntegrations(
12081
- this._options
12732
+ /**
12733
+ * Create an evaluation rule.
12734
+ *
12735
+ * An evaluation rule defines **what** incoming data should be evaluated and **how prompt variables should be populated** from that data.
12736
+ *
12737
+ * Use this resource after choosing an evaluator from the evaluator endpoints.
12738
+ *
12739
+ * Key rules:
12740
+ * - `name` must be unique within the project for public evaluation rules
12741
+ * - `target` must be `observation` or `experiment`
12742
+ * - `evaluator.name` + `evaluator.scope` must identify an existing evaluator family returned by the evaluator endpoints
12743
+ * - Langfuse resolves that family to its latest version before saving the evaluation rule
12744
+ * - for `target=experiment`, use dataset `id` values from `GET /api/public/v2/datasets` when filtering by `datasetId`
12745
+ * - for `llm_as_judge` evaluators, every evaluator prompt variable must be mapped exactly once
12746
+ * - for `code` evaluators, Langfuse uses the fixed code runtime mapping; omit `mapping` in create and update requests
12747
+ * - for user-provided `llm_as_judge` mappings, `expected_output` and `experiment_item_metadata` are only valid for `target=experiment`
12748
+ * - if `enabled=true`, Langfuse validates that the referenced evaluator can currently run
12749
+ * - at most 50 evaluation rules can be effectively active in one project at the same time
12750
+ *
12751
+ * If an evaluation rule with the same `name` already exists in the project, the API returns `409`.
12752
+ * In that case, update the existing resource with `PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}` instead of creating a second one.
12753
+ *
12754
+ * If enabling this resource would exceed the 50-active limit, the API also returns `409`.
12755
+ * In that case, disable or pause another active evaluation rule before enabling a new one.
12756
+ *
12757
+ * Current scope:
12758
+ * - evaluation rules are live-ingestion rules only
12759
+ * - they do not trigger historical backfills
12760
+ *
12761
+ * Recovery guidance:
12762
+ * - `400 invalid_filter_value`: fix the filter `column` or `value` using `details.column`, `details.invalidValues`, and `details.allowedValues`
12763
+ * - `400 invalid_filter_value` with `details.column=datasetId`: call `GET /api/public/v2/datasets`, then retry with dataset `id` values from that response
12764
+ * - `400 missing_variable_mapping`: for `llm_as_judge` evaluators, fetch the evaluator again and make sure every variable in `variables` appears exactly once in `mapping`
12765
+ * - `400 duplicate_variable_mapping`: remove repeated mappings for the same variable
12766
+ * - `400 invalid_variable_mapping`: for `llm_as_judge`, switch to a valid `source` for the selected `target`, or fix the variable name
12767
+ * - `400 invalid_json_path`: remove or correct the `jsonPath`
12768
+ * - `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.
12769
+ *
12770
+ * @param {LangfuseAPI.unstable.CreateEvaluationRuleRequest} request
12771
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
12772
+ *
12773
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
12774
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
12775
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
12776
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
12777
+ * @throws {@link LangfuseAPI.unstable.ConflictError}
12778
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
12779
+ * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
12780
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
12781
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
12782
+ * @throws {@link LangfuseAPI.Error}
12783
+ * @throws {@link LangfuseAPI.UnauthorizedError}
12784
+ * @throws {@link LangfuseAPI.AccessDeniedError}
12785
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
12786
+ * @throws {@link LangfuseAPI.NotFoundError}
12787
+ *
12788
+ * @example
12789
+ * await client.unstable.evaluationRules.create({
12790
+ * name: "answer-correctness-live",
12791
+ * evaluator: {
12792
+ * name: "answer-correctness",
12793
+ * scope: "project",
12794
+ * type: "llm_as_judge"
12795
+ * },
12796
+ * target: "observation",
12797
+ * enabled: true,
12798
+ * sampling: 1,
12799
+ * filter: [{
12800
+ * type: "stringOptions",
12801
+ * column: "type",
12802
+ * operator: "any of",
12803
+ * value: ["GENERATION"]
12804
+ * }],
12805
+ * mapping: [{
12806
+ * variable: "input",
12807
+ * source: "input"
12808
+ * }, {
12809
+ * variable: "output",
12810
+ * source: "output"
12811
+ * }]
12812
+ * })
12813
+ *
12814
+ * @example
12815
+ * await client.unstable.evaluationRules.create({
12816
+ * name: "toxicity-code-live",
12817
+ * evaluator: {
12818
+ * name: "toxicity-detector",
12819
+ * scope: "project",
12820
+ * type: "code"
12821
+ * },
12822
+ * target: "observation",
12823
+ * enabled: true,
12824
+ * sampling: 1,
12825
+ * filter: [{
12826
+ * type: "stringOptions",
12827
+ * column: "type",
12828
+ * operator: "any of",
12829
+ * value: ["GENERATION"]
12830
+ * }]
12831
+ * })
12832
+ *
12833
+ * @example
12834
+ * await client.unstable.evaluationRules.create({
12835
+ * name: "experiment-expected-output-match",
12836
+ * evaluator: {
12837
+ * name: "expected-output-match",
12838
+ * scope: "project",
12839
+ * type: "llm_as_judge"
12840
+ * },
12841
+ * target: "experiment",
12842
+ * enabled: true,
12843
+ * sampling: 0.5,
12844
+ * filter: [{
12845
+ * type: "stringOptions",
12846
+ * column: "datasetId",
12847
+ * operator: "any of",
12848
+ * value: ["550e8400-e29b-41d4-a716-446655440000"]
12849
+ * }],
12850
+ * mapping: [{
12851
+ * variable: "output",
12852
+ * source: "output"
12853
+ * }, {
12854
+ * variable: "expected_output",
12855
+ * source: "expected_output"
12856
+ * }]
12857
+ * })
12858
+ */
12859
+ create(request, requestOptions) {
12860
+ return HttpResponsePromise.fromPromise(
12861
+ this.__create(request, requestOptions)
12082
12862
  );
12083
12863
  }
12084
- get comments() {
12085
- var _a2;
12086
- return (_a2 = this._comments) != null ? _a2 : this._comments = new Comments(this._options);
12087
- }
12088
- get datasetItems() {
12089
- var _a2;
12090
- return (_a2 = this._datasetItems) != null ? _a2 : this._datasetItems = new DatasetItems(this._options);
12091
- }
12092
- get datasetRunItems() {
12093
- var _a2;
12864
+ async __create(request, requestOptions) {
12865
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
12866
+ let _headers = mergeHeaders(
12867
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
12868
+ mergeOnlyDefinedHeaders({
12869
+ Authorization: await this._getAuthorizationHeader(),
12870
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
12871
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
12872
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
12873
+ }),
12874
+ requestOptions == null ? void 0 : requestOptions.headers
12875
+ );
12876
+ const _response = await fetcher({
12877
+ url: url_exports.join(
12878
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
12879
+ "/api/public/unstable/evaluation-rules"
12880
+ ),
12881
+ method: "POST",
12882
+ headers: _headers,
12883
+ contentType: "application/json",
12884
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
12885
+ requestType: "json",
12886
+ body: request,
12887
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
12888
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
12889
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
12890
+ });
12891
+ if (_response.ok) {
12892
+ return {
12893
+ data: _response.body,
12894
+ rawResponse: _response.rawResponse
12895
+ };
12896
+ }
12897
+ if (_response.error.reason === "status-code") {
12898
+ switch (_response.error.statusCode) {
12899
+ case 400:
12900
+ throw new unstable_exports.BadRequestError(
12901
+ _response.error.body,
12902
+ _response.rawResponse
12903
+ );
12904
+ case 401:
12905
+ throw new unstable_exports.UnauthorizedError(
12906
+ _response.error.body,
12907
+ _response.rawResponse
12908
+ );
12909
+ case 403:
12910
+ throw new unstable_exports.AccessDeniedError(
12911
+ _response.error.body,
12912
+ _response.rawResponse
12913
+ );
12914
+ case 404:
12915
+ throw new unstable_exports.NotFoundError(
12916
+ _response.error.body,
12917
+ _response.rawResponse
12918
+ );
12919
+ case 409:
12920
+ throw new unstable_exports.ConflictError(
12921
+ _response.error.body,
12922
+ _response.rawResponse
12923
+ );
12924
+ case 405:
12925
+ throw new unstable_exports.MethodNotAllowedError(
12926
+ _response.error.body,
12927
+ _response.rawResponse
12928
+ );
12929
+ case 422:
12930
+ throw new unstable_exports.UnprocessableContentError(
12931
+ _response.error.body,
12932
+ _response.rawResponse
12933
+ );
12934
+ case 429:
12935
+ throw new unstable_exports.TooManyRequestsError(
12936
+ _response.error.body,
12937
+ _response.rawResponse
12938
+ );
12939
+ case 500:
12940
+ throw new unstable_exports.InternalServerError(
12941
+ _response.error.body,
12942
+ _response.rawResponse
12943
+ );
12944
+ case 400:
12945
+ throw new Error2(
12946
+ _response.error.body,
12947
+ _response.rawResponse
12948
+ );
12949
+ case 401:
12950
+ throw new UnauthorizedError(
12951
+ _response.error.body,
12952
+ _response.rawResponse
12953
+ );
12954
+ case 403:
12955
+ throw new AccessDeniedError(
12956
+ _response.error.body,
12957
+ _response.rawResponse
12958
+ );
12959
+ case 405:
12960
+ throw new MethodNotAllowedError(
12961
+ _response.error.body,
12962
+ _response.rawResponse
12963
+ );
12964
+ case 404:
12965
+ throw new NotFoundError(
12966
+ _response.error.body,
12967
+ _response.rawResponse
12968
+ );
12969
+ default:
12970
+ throw new LangfuseAPIError({
12971
+ statusCode: _response.error.statusCode,
12972
+ body: _response.error.body,
12973
+ rawResponse: _response.rawResponse
12974
+ });
12975
+ }
12976
+ }
12977
+ switch (_response.error.reason) {
12978
+ case "non-json":
12979
+ throw new LangfuseAPIError({
12980
+ statusCode: _response.error.statusCode,
12981
+ body: _response.error.rawBody,
12982
+ rawResponse: _response.rawResponse
12983
+ });
12984
+ case "timeout":
12985
+ throw new LangfuseAPITimeoutError(
12986
+ "Timeout exceeded when calling POST /api/public/unstable/evaluation-rules."
12987
+ );
12988
+ case "unknown":
12989
+ throw new LangfuseAPIError({
12990
+ message: _response.error.errorMessage,
12991
+ rawResponse: _response.rawResponse
12992
+ });
12993
+ }
12994
+ }
12995
+ /**
12996
+ * List evaluation rules in the authenticated project.
12997
+ *
12998
+ * Each item describes one live evaluation rule and its effective runtime status.
12999
+ *
13000
+ * @param {LangfuseAPI.unstable.ListEvaluationRulesRequest} request
13001
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
13002
+ *
13003
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13004
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13005
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13006
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13007
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13008
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13009
+ * @throws {@link LangfuseAPI.Error}
13010
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13011
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13012
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13013
+ * @throws {@link LangfuseAPI.NotFoundError}
13014
+ *
13015
+ * @example
13016
+ * await client.unstable.evaluationRules.list()
13017
+ */
13018
+ list(request = {}, requestOptions) {
13019
+ return HttpResponsePromise.fromPromise(
13020
+ this.__list(request, requestOptions)
13021
+ );
13022
+ }
13023
+ async __list(request = {}, requestOptions) {
13024
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13025
+ const { page, limit } = request;
13026
+ const _queryParams = {};
13027
+ if (page != null) {
13028
+ _queryParams["page"] = page.toString();
13029
+ }
13030
+ if (limit != null) {
13031
+ _queryParams["limit"] = limit.toString();
13032
+ }
13033
+ let _headers = mergeHeaders(
13034
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13035
+ mergeOnlyDefinedHeaders({
13036
+ Authorization: await this._getAuthorizationHeader(),
13037
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13038
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13039
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13040
+ }),
13041
+ requestOptions == null ? void 0 : requestOptions.headers
13042
+ );
13043
+ const _response = await fetcher({
13044
+ url: url_exports.join(
13045
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13046
+ "/api/public/unstable/evaluation-rules"
13047
+ ),
13048
+ method: "GET",
13049
+ headers: _headers,
13050
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
13051
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13052
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13053
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13054
+ });
13055
+ if (_response.ok) {
13056
+ return {
13057
+ data: _response.body,
13058
+ rawResponse: _response.rawResponse
13059
+ };
13060
+ }
13061
+ if (_response.error.reason === "status-code") {
13062
+ switch (_response.error.statusCode) {
13063
+ case 400:
13064
+ throw new unstable_exports.BadRequestError(
13065
+ _response.error.body,
13066
+ _response.rawResponse
13067
+ );
13068
+ case 401:
13069
+ throw new unstable_exports.UnauthorizedError(
13070
+ _response.error.body,
13071
+ _response.rawResponse
13072
+ );
13073
+ case 403:
13074
+ throw new unstable_exports.AccessDeniedError(
13075
+ _response.error.body,
13076
+ _response.rawResponse
13077
+ );
13078
+ case 405:
13079
+ throw new unstable_exports.MethodNotAllowedError(
13080
+ _response.error.body,
13081
+ _response.rawResponse
13082
+ );
13083
+ case 429:
13084
+ throw new unstable_exports.TooManyRequestsError(
13085
+ _response.error.body,
13086
+ _response.rawResponse
13087
+ );
13088
+ case 500:
13089
+ throw new unstable_exports.InternalServerError(
13090
+ _response.error.body,
13091
+ _response.rawResponse
13092
+ );
13093
+ case 400:
13094
+ throw new Error2(
13095
+ _response.error.body,
13096
+ _response.rawResponse
13097
+ );
13098
+ case 401:
13099
+ throw new UnauthorizedError(
13100
+ _response.error.body,
13101
+ _response.rawResponse
13102
+ );
13103
+ case 403:
13104
+ throw new AccessDeniedError(
13105
+ _response.error.body,
13106
+ _response.rawResponse
13107
+ );
13108
+ case 405:
13109
+ throw new MethodNotAllowedError(
13110
+ _response.error.body,
13111
+ _response.rawResponse
13112
+ );
13113
+ case 404:
13114
+ throw new NotFoundError(
13115
+ _response.error.body,
13116
+ _response.rawResponse
13117
+ );
13118
+ default:
13119
+ throw new LangfuseAPIError({
13120
+ statusCode: _response.error.statusCode,
13121
+ body: _response.error.body,
13122
+ rawResponse: _response.rawResponse
13123
+ });
13124
+ }
13125
+ }
13126
+ switch (_response.error.reason) {
13127
+ case "non-json":
13128
+ throw new LangfuseAPIError({
13129
+ statusCode: _response.error.statusCode,
13130
+ body: _response.error.rawBody,
13131
+ rawResponse: _response.rawResponse
13132
+ });
13133
+ case "timeout":
13134
+ throw new LangfuseAPITimeoutError(
13135
+ "Timeout exceeded when calling GET /api/public/unstable/evaluation-rules."
13136
+ );
13137
+ case "unknown":
13138
+ throw new LangfuseAPIError({
13139
+ message: _response.error.errorMessage,
13140
+ rawResponse: _response.rawResponse
13141
+ });
13142
+ }
13143
+ }
13144
+ /**
13145
+ * Get one evaluation rule by its identifier.
13146
+ *
13147
+ * Use this endpoint to inspect the current evaluator, target, mapping, filters, and effective runtime status.
13148
+ *
13149
+ * @param {string} evaluationRuleId - Evaluation rule identifier returned by the evaluation rule endpoints.
13150
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
13151
+ *
13152
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13153
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13154
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13155
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
13156
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13157
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13158
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13159
+ * @throws {@link LangfuseAPI.Error}
13160
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13161
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13162
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13163
+ * @throws {@link LangfuseAPI.NotFoundError}
13164
+ *
13165
+ * @example
13166
+ * await client.unstable.evaluationRules.get("evaluationRuleId")
13167
+ */
13168
+ get(evaluationRuleId, requestOptions) {
13169
+ return HttpResponsePromise.fromPromise(
13170
+ this.__get(evaluationRuleId, requestOptions)
13171
+ );
13172
+ }
13173
+ async __get(evaluationRuleId, requestOptions) {
13174
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13175
+ let _headers = mergeHeaders(
13176
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13177
+ mergeOnlyDefinedHeaders({
13178
+ Authorization: await this._getAuthorizationHeader(),
13179
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13180
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13181
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13182
+ }),
13183
+ requestOptions == null ? void 0 : requestOptions.headers
13184
+ );
13185
+ const _response = await fetcher({
13186
+ url: url_exports.join(
13187
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13188
+ `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
13189
+ ),
13190
+ method: "GET",
13191
+ headers: _headers,
13192
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13193
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13194
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13195
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13196
+ });
13197
+ if (_response.ok) {
13198
+ return {
13199
+ data: _response.body,
13200
+ rawResponse: _response.rawResponse
13201
+ };
13202
+ }
13203
+ if (_response.error.reason === "status-code") {
13204
+ switch (_response.error.statusCode) {
13205
+ case 400:
13206
+ throw new unstable_exports.BadRequestError(
13207
+ _response.error.body,
13208
+ _response.rawResponse
13209
+ );
13210
+ case 401:
13211
+ throw new unstable_exports.UnauthorizedError(
13212
+ _response.error.body,
13213
+ _response.rawResponse
13214
+ );
13215
+ case 403:
13216
+ throw new unstable_exports.AccessDeniedError(
13217
+ _response.error.body,
13218
+ _response.rawResponse
13219
+ );
13220
+ case 404:
13221
+ throw new unstable_exports.NotFoundError(
13222
+ _response.error.body,
13223
+ _response.rawResponse
13224
+ );
13225
+ case 405:
13226
+ throw new unstable_exports.MethodNotAllowedError(
13227
+ _response.error.body,
13228
+ _response.rawResponse
13229
+ );
13230
+ case 429:
13231
+ throw new unstable_exports.TooManyRequestsError(
13232
+ _response.error.body,
13233
+ _response.rawResponse
13234
+ );
13235
+ case 500:
13236
+ throw new unstable_exports.InternalServerError(
13237
+ _response.error.body,
13238
+ _response.rawResponse
13239
+ );
13240
+ case 400:
13241
+ throw new Error2(
13242
+ _response.error.body,
13243
+ _response.rawResponse
13244
+ );
13245
+ case 401:
13246
+ throw new UnauthorizedError(
13247
+ _response.error.body,
13248
+ _response.rawResponse
13249
+ );
13250
+ case 403:
13251
+ throw new AccessDeniedError(
13252
+ _response.error.body,
13253
+ _response.rawResponse
13254
+ );
13255
+ case 405:
13256
+ throw new MethodNotAllowedError(
13257
+ _response.error.body,
13258
+ _response.rawResponse
13259
+ );
13260
+ case 404:
13261
+ throw new NotFoundError(
13262
+ _response.error.body,
13263
+ _response.rawResponse
13264
+ );
13265
+ default:
13266
+ throw new LangfuseAPIError({
13267
+ statusCode: _response.error.statusCode,
13268
+ body: _response.error.body,
13269
+ rawResponse: _response.rawResponse
13270
+ });
13271
+ }
13272
+ }
13273
+ switch (_response.error.reason) {
13274
+ case "non-json":
13275
+ throw new LangfuseAPIError({
13276
+ statusCode: _response.error.statusCode,
13277
+ body: _response.error.rawBody,
13278
+ rawResponse: _response.rawResponse
13279
+ });
13280
+ case "timeout":
13281
+ throw new LangfuseAPITimeoutError(
13282
+ "Timeout exceeded when calling GET /api/public/unstable/evaluation-rules/{evaluationRuleId}."
13283
+ );
13284
+ case "unknown":
13285
+ throw new LangfuseAPIError({
13286
+ message: _response.error.errorMessage,
13287
+ rawResponse: _response.rawResponse
13288
+ });
13289
+ }
13290
+ }
13291
+ /**
13292
+ * Update an evaluation rule.
13293
+ *
13294
+ * Typical uses:
13295
+ * - enable or disable live execution
13296
+ * - switch to another evaluator
13297
+ * - adjust sampling
13298
+ * - change filters
13299
+ * - update LLM-as-judge variable mappings
13300
+ *
13301
+ * Important behavior:
13302
+ * - provide only the fields you want to change
13303
+ * - if you provide `evaluator`, Langfuse resolves that evaluator family to its latest version before saving
13304
+ * - changing `target`, `filter`, or an LLM-as-judge `mapping` must still produce a valid target-specific configuration
13305
+ * - if you change `target` for an LLM-as-judge rule, also send a compatible `filter` and `mapping` in the same request unless the existing ones are still valid for the new target
13306
+ * - for `code` evaluator rules, omit `mapping`; Langfuse stores the fixed code runtime mapping automatically
13307
+ * - if the resulting config is enabled, Langfuse re-validates that the selected evaluator can run
13308
+ * - 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`
13309
+ *
13310
+ * Recovery guidance:
13311
+ * - if an LLM-as-judge update fails with `missing_variable_mapping` or `invalid_variable_mapping` after changing `evaluator` or `target`, resend the request with a complete new `mapping`
13312
+ * - if the update fails with `invalid_filter_value` after changing `target`, resend the request with a target-compatible `filter`
13313
+ *
13314
+ * @param {string} evaluationRuleId - Evaluation rule identifier.
13315
+ * @param {LangfuseAPI.unstable.UpdateEvaluationRuleRequest} request
13316
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
13317
+ *
13318
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13319
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13320
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13321
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
13322
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13323
+ * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
13324
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13325
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13326
+ * @throws {@link LangfuseAPI.Error}
13327
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13328
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13329
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13330
+ * @throws {@link LangfuseAPI.NotFoundError}
13331
+ *
13332
+ * @example
13333
+ * await client.unstable.evaluationRules.update("evaluationRuleId", {
13334
+ * name: undefined,
13335
+ * evaluator: undefined,
13336
+ * target: undefined,
13337
+ * enabled: undefined,
13338
+ * sampling: undefined,
13339
+ * filter: undefined,
13340
+ * mapping: undefined
13341
+ * })
13342
+ */
13343
+ update(evaluationRuleId, request, requestOptions) {
13344
+ return HttpResponsePromise.fromPromise(
13345
+ this.__update(evaluationRuleId, request, requestOptions)
13346
+ );
13347
+ }
13348
+ async __update(evaluationRuleId, request, requestOptions) {
13349
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13350
+ let _headers = mergeHeaders(
13351
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13352
+ mergeOnlyDefinedHeaders({
13353
+ Authorization: await this._getAuthorizationHeader(),
13354
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13355
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13356
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13357
+ }),
13358
+ requestOptions == null ? void 0 : requestOptions.headers
13359
+ );
13360
+ const _response = await fetcher({
13361
+ url: url_exports.join(
13362
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13363
+ `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
13364
+ ),
13365
+ method: "PATCH",
13366
+ headers: _headers,
13367
+ contentType: "application/json",
13368
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13369
+ requestType: "json",
13370
+ body: request,
13371
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13372
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13373
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13374
+ });
13375
+ if (_response.ok) {
13376
+ return {
13377
+ data: _response.body,
13378
+ rawResponse: _response.rawResponse
13379
+ };
13380
+ }
13381
+ if (_response.error.reason === "status-code") {
13382
+ switch (_response.error.statusCode) {
13383
+ case 400:
13384
+ throw new unstable_exports.BadRequestError(
13385
+ _response.error.body,
13386
+ _response.rawResponse
13387
+ );
13388
+ case 401:
13389
+ throw new unstable_exports.UnauthorizedError(
13390
+ _response.error.body,
13391
+ _response.rawResponse
13392
+ );
13393
+ case 403:
13394
+ throw new unstable_exports.AccessDeniedError(
13395
+ _response.error.body,
13396
+ _response.rawResponse
13397
+ );
13398
+ case 404:
13399
+ throw new unstable_exports.NotFoundError(
13400
+ _response.error.body,
13401
+ _response.rawResponse
13402
+ );
13403
+ case 405:
13404
+ throw new unstable_exports.MethodNotAllowedError(
13405
+ _response.error.body,
13406
+ _response.rawResponse
13407
+ );
13408
+ case 422:
13409
+ throw new unstable_exports.UnprocessableContentError(
13410
+ _response.error.body,
13411
+ _response.rawResponse
13412
+ );
13413
+ case 429:
13414
+ throw new unstable_exports.TooManyRequestsError(
13415
+ _response.error.body,
13416
+ _response.rawResponse
13417
+ );
13418
+ case 500:
13419
+ throw new unstable_exports.InternalServerError(
13420
+ _response.error.body,
13421
+ _response.rawResponse
13422
+ );
13423
+ case 400:
13424
+ throw new Error2(
13425
+ _response.error.body,
13426
+ _response.rawResponse
13427
+ );
13428
+ case 401:
13429
+ throw new UnauthorizedError(
13430
+ _response.error.body,
13431
+ _response.rawResponse
13432
+ );
13433
+ case 403:
13434
+ throw new AccessDeniedError(
13435
+ _response.error.body,
13436
+ _response.rawResponse
13437
+ );
13438
+ case 405:
13439
+ throw new MethodNotAllowedError(
13440
+ _response.error.body,
13441
+ _response.rawResponse
13442
+ );
13443
+ case 404:
13444
+ throw new NotFoundError(
13445
+ _response.error.body,
13446
+ _response.rawResponse
13447
+ );
13448
+ default:
13449
+ throw new LangfuseAPIError({
13450
+ statusCode: _response.error.statusCode,
13451
+ body: _response.error.body,
13452
+ rawResponse: _response.rawResponse
13453
+ });
13454
+ }
13455
+ }
13456
+ switch (_response.error.reason) {
13457
+ case "non-json":
13458
+ throw new LangfuseAPIError({
13459
+ statusCode: _response.error.statusCode,
13460
+ body: _response.error.rawBody,
13461
+ rawResponse: _response.rawResponse
13462
+ });
13463
+ case "timeout":
13464
+ throw new LangfuseAPITimeoutError(
13465
+ "Timeout exceeded when calling PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}."
13466
+ );
13467
+ case "unknown":
13468
+ throw new LangfuseAPIError({
13469
+ message: _response.error.errorMessage,
13470
+ rawResponse: _response.rawResponse
13471
+ });
13472
+ }
13473
+ }
13474
+ /**
13475
+ * Delete an evaluation rule.
13476
+ *
13477
+ * This removes the live-ingestion rule only. It does not delete the referenced evaluator.
13478
+ *
13479
+ * @param {string} evaluationRuleId - Evaluation rule identifier.
13480
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
13481
+ *
13482
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13483
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13484
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13485
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
13486
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13487
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13488
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13489
+ * @throws {@link LangfuseAPI.Error}
13490
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13491
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13492
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13493
+ * @throws {@link LangfuseAPI.NotFoundError}
13494
+ *
13495
+ * @example
13496
+ * await client.unstable.evaluationRules.delete("evaluationRuleId")
13497
+ */
13498
+ delete(evaluationRuleId, requestOptions) {
13499
+ return HttpResponsePromise.fromPromise(
13500
+ this.__delete(evaluationRuleId, requestOptions)
13501
+ );
13502
+ }
13503
+ async __delete(evaluationRuleId, requestOptions) {
13504
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13505
+ let _headers = mergeHeaders(
13506
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13507
+ mergeOnlyDefinedHeaders({
13508
+ Authorization: await this._getAuthorizationHeader(),
13509
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13510
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13511
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13512
+ }),
13513
+ requestOptions == null ? void 0 : requestOptions.headers
13514
+ );
13515
+ const _response = await fetcher({
13516
+ url: url_exports.join(
13517
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13518
+ `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
13519
+ ),
13520
+ method: "DELETE",
13521
+ headers: _headers,
13522
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13523
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13524
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13525
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13526
+ });
13527
+ if (_response.ok) {
13528
+ return {
13529
+ data: _response.body,
13530
+ rawResponse: _response.rawResponse
13531
+ };
13532
+ }
13533
+ if (_response.error.reason === "status-code") {
13534
+ switch (_response.error.statusCode) {
13535
+ case 400:
13536
+ throw new unstable_exports.BadRequestError(
13537
+ _response.error.body,
13538
+ _response.rawResponse
13539
+ );
13540
+ case 401:
13541
+ throw new unstable_exports.UnauthorizedError(
13542
+ _response.error.body,
13543
+ _response.rawResponse
13544
+ );
13545
+ case 403:
13546
+ throw new unstable_exports.AccessDeniedError(
13547
+ _response.error.body,
13548
+ _response.rawResponse
13549
+ );
13550
+ case 404:
13551
+ throw new unstable_exports.NotFoundError(
13552
+ _response.error.body,
13553
+ _response.rawResponse
13554
+ );
13555
+ case 405:
13556
+ throw new unstable_exports.MethodNotAllowedError(
13557
+ _response.error.body,
13558
+ _response.rawResponse
13559
+ );
13560
+ case 429:
13561
+ throw new unstable_exports.TooManyRequestsError(
13562
+ _response.error.body,
13563
+ _response.rawResponse
13564
+ );
13565
+ case 500:
13566
+ throw new unstable_exports.InternalServerError(
13567
+ _response.error.body,
13568
+ _response.rawResponse
13569
+ );
13570
+ case 400:
13571
+ throw new Error2(
13572
+ _response.error.body,
13573
+ _response.rawResponse
13574
+ );
13575
+ case 401:
13576
+ throw new UnauthorizedError(
13577
+ _response.error.body,
13578
+ _response.rawResponse
13579
+ );
13580
+ case 403:
13581
+ throw new AccessDeniedError(
13582
+ _response.error.body,
13583
+ _response.rawResponse
13584
+ );
13585
+ case 405:
13586
+ throw new MethodNotAllowedError(
13587
+ _response.error.body,
13588
+ _response.rawResponse
13589
+ );
13590
+ case 404:
13591
+ throw new NotFoundError(
13592
+ _response.error.body,
13593
+ _response.rawResponse
13594
+ );
13595
+ default:
13596
+ throw new LangfuseAPIError({
13597
+ statusCode: _response.error.statusCode,
13598
+ body: _response.error.body,
13599
+ rawResponse: _response.rawResponse
13600
+ });
13601
+ }
13602
+ }
13603
+ switch (_response.error.reason) {
13604
+ case "non-json":
13605
+ throw new LangfuseAPIError({
13606
+ statusCode: _response.error.statusCode,
13607
+ body: _response.error.rawBody,
13608
+ rawResponse: _response.rawResponse
13609
+ });
13610
+ case "timeout":
13611
+ throw new LangfuseAPITimeoutError(
13612
+ "Timeout exceeded when calling DELETE /api/public/unstable/evaluation-rules/{evaluationRuleId}."
13613
+ );
13614
+ case "unknown":
13615
+ throw new LangfuseAPIError({
13616
+ message: _response.error.errorMessage,
13617
+ rawResponse: _response.rawResponse
13618
+ });
13619
+ }
13620
+ }
13621
+ async _getAuthorizationHeader() {
13622
+ const username = await Supplier.get(this._options.username);
13623
+ const password = await Supplier.get(this._options.password);
13624
+ if (username != null && password != null) {
13625
+ return BasicAuth.toAuthorizationHeader({
13626
+ username,
13627
+ password
13628
+ });
13629
+ }
13630
+ return void 0;
13631
+ }
13632
+ };
13633
+
13634
+ // src/api/api/resources/unstable/resources/evaluators/client/Client.ts
13635
+ var Evaluators = class {
13636
+ constructor(_options) {
13637
+ this._options = _options;
13638
+ }
13639
+ /**
13640
+ * Create an evaluator in the authenticated project.
13641
+ *
13642
+ * Use evaluators to define **how** Langfuse should score data.
13643
+ * LLM-as-a-judge evaluators define a prompt, expected structured output, and optional model configuration.
13644
+ * Code evaluators define source code and a runtime language.
13645
+ *
13646
+ * Naming behavior:
13647
+ * - If this is a new evaluator name in your project, Langfuse creates version `1`.
13648
+ * - If the name already exists in your project, Langfuse creates the next version and returns it.
13649
+ * - When a new project version is created, existing evaluation rules in that project automatically move to the newest version for that evaluator name.
13650
+ *
13651
+ * Recommended workflow:
13652
+ * 1. Create the evaluator.
13653
+ * 2. Read the returned `variables` array.
13654
+ * 3. Read the returned `outputDefinition.dataType` so the client knows whether future scores will be numeric, boolean, or categorical.
13655
+ * 4. Create one or more evaluation rules that reference the returned evaluator family using `name` and `scope`.
13656
+ *
13657
+ * Code evaluator validation:
13658
+ * - At creation, Langfuse only validates the request shape
13659
+ * - The `sourceCode` itself is not executed here. It is first run (preflight-tested against a sample observation) when you link the evaluator to an evaluation rule, so runtime errors in the code surface at evaluation-rule creation, not at evaluator creation.
13660
+ *
13661
+ * Recovery guidance:
13662
+ * - `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.
13663
+ * - `400` with `code=invalid_body`: the request shape is malformed. Use the structured `details.issues` array to fix the specific fields and retry.
13664
+ * - `400` with `code=invalid_body` on `outputDefinition`: for `type=llm_as_judge`, send `dataType`, `reasoning.description`, and `score.description`. Do not send `version`; it is not part of the public request shape.
13665
+ * - If `type` is omitted, Langfuse treats the request as `type=llm_as_judge` for backwards compatibility. New clients should send `type` explicitly.
13666
+ *
13667
+ * Unstable API note:
13668
+ * - This surface may evolve while the underlying evaluation data model is being redesigned.
13669
+ *
13670
+ * @param {LangfuseAPI.unstable.CreateEvaluatorRequest} request
13671
+ * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
13672
+ *
13673
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13674
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13675
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13676
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13677
+ * @throws {@link LangfuseAPI.unstable.ConflictError}
13678
+ * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
13679
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13680
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13681
+ * @throws {@link LangfuseAPI.Error}
13682
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13683
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13684
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13685
+ * @throws {@link LangfuseAPI.NotFoundError}
13686
+ *
13687
+ * @example
13688
+ * await client.unstable.evaluators.create({
13689
+ * type: "llm_as_judge",
13690
+ * name: "answer-correctness",
13691
+ * prompt: "You are grading an answer.\n\nInput:\n{{input}}\n\nOutput:\n{{output}}\n\nReturn a score between 0 and 1.\n",
13692
+ * outputDefinition: {
13693
+ * dataType: "NUMERIC",
13694
+ * dataType: "NUMERIC",
13695
+ * reasoning: {
13696
+ * description: "Explain why the score was assigned."
13697
+ * },
13698
+ * score: {
13699
+ * description: "Correctness score between 0 and 1."
13700
+ * }
13701
+ * },
13702
+ * modelConfig: {
13703
+ * provider: "openai",
13704
+ * model: "gpt-4.1-mini"
13705
+ * }
13706
+ * })
13707
+ *
13708
+ * @example
13709
+ * await client.unstable.evaluators.create({
13710
+ * type: "code",
13711
+ * name: "exact-match",
13712
+ * sourceCode: "function evaluate(ctx: EvaluationContext): EvaluationResult {\n const input = ctx.observation.input;\n const matchesOutput =\n input !== undefined && ctx.observation.output === input;\n\n return {\n scores: [\n {\n name: \"Exact match\",\n value: matchesOutput,\n dataType: \"BOOLEAN\",\n comment: matchesOutput\n ? \"Output exactly matches the input.\"\n : \"Output does not match the input.\",\n },\n ],\n };\n}\n",
13713
+ * sourceCodeLanguage: "TYPESCRIPT"
13714
+ * })
13715
+ *
13716
+ * @example
13717
+ * await client.unstable.evaluators.create({
13718
+ * type: "code",
13719
+ * name: "exact-match",
13720
+ * sourceCode: "def evaluate(ctx: EvaluationContext) -> EvaluationResult:\n \"\"\"Evaluates one observation and returns one or more Langfuse scores.\"\"\"\n input = ctx.observation.input\n matches_output = input is not None and ctx.observation.output == input\n\n return EvaluationResult(\n scores=[\n Score(\n name=\"Exact match\",\n value=matches_output,\n data_type=\"BOOLEAN\",\n comment=(\n \"Output exactly matches the input.\"\n if matches_output\n else \"Output does not match the input.\"\n ),\n )\n ]\n )\n",
13721
+ * sourceCodeLanguage: "PYTHON"
13722
+ * })
13723
+ */
13724
+ create(request, requestOptions) {
13725
+ return HttpResponsePromise.fromPromise(
13726
+ this.__create(request, requestOptions)
13727
+ );
13728
+ }
13729
+ async __create(request, requestOptions) {
13730
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13731
+ let _headers = mergeHeaders(
13732
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13733
+ mergeOnlyDefinedHeaders({
13734
+ Authorization: await this._getAuthorizationHeader(),
13735
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13736
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13737
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13738
+ }),
13739
+ requestOptions == null ? void 0 : requestOptions.headers
13740
+ );
13741
+ const _response = await fetcher({
13742
+ url: url_exports.join(
13743
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13744
+ "/api/public/unstable/evaluators"
13745
+ ),
13746
+ method: "POST",
13747
+ headers: _headers,
13748
+ contentType: "application/json",
13749
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13750
+ requestType: "json",
13751
+ body: request,
13752
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13753
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13754
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13755
+ });
13756
+ if (_response.ok) {
13757
+ return {
13758
+ data: _response.body,
13759
+ rawResponse: _response.rawResponse
13760
+ };
13761
+ }
13762
+ if (_response.error.reason === "status-code") {
13763
+ switch (_response.error.statusCode) {
13764
+ case 400:
13765
+ throw new unstable_exports.BadRequestError(
13766
+ _response.error.body,
13767
+ _response.rawResponse
13768
+ );
13769
+ case 401:
13770
+ throw new unstable_exports.UnauthorizedError(
13771
+ _response.error.body,
13772
+ _response.rawResponse
13773
+ );
13774
+ case 403:
13775
+ throw new unstable_exports.AccessDeniedError(
13776
+ _response.error.body,
13777
+ _response.rawResponse
13778
+ );
13779
+ case 405:
13780
+ throw new unstable_exports.MethodNotAllowedError(
13781
+ _response.error.body,
13782
+ _response.rawResponse
13783
+ );
13784
+ case 409:
13785
+ throw new unstable_exports.ConflictError(
13786
+ _response.error.body,
13787
+ _response.rawResponse
13788
+ );
13789
+ case 422:
13790
+ throw new unstable_exports.UnprocessableContentError(
13791
+ _response.error.body,
13792
+ _response.rawResponse
13793
+ );
13794
+ case 429:
13795
+ throw new unstable_exports.TooManyRequestsError(
13796
+ _response.error.body,
13797
+ _response.rawResponse
13798
+ );
13799
+ case 500:
13800
+ throw new unstable_exports.InternalServerError(
13801
+ _response.error.body,
13802
+ _response.rawResponse
13803
+ );
13804
+ case 400:
13805
+ throw new Error2(
13806
+ _response.error.body,
13807
+ _response.rawResponse
13808
+ );
13809
+ case 401:
13810
+ throw new UnauthorizedError(
13811
+ _response.error.body,
13812
+ _response.rawResponse
13813
+ );
13814
+ case 403:
13815
+ throw new AccessDeniedError(
13816
+ _response.error.body,
13817
+ _response.rawResponse
13818
+ );
13819
+ case 405:
13820
+ throw new MethodNotAllowedError(
13821
+ _response.error.body,
13822
+ _response.rawResponse
13823
+ );
13824
+ case 404:
13825
+ throw new NotFoundError(
13826
+ _response.error.body,
13827
+ _response.rawResponse
13828
+ );
13829
+ default:
13830
+ throw new LangfuseAPIError({
13831
+ statusCode: _response.error.statusCode,
13832
+ body: _response.error.body,
13833
+ rawResponse: _response.rawResponse
13834
+ });
13835
+ }
13836
+ }
13837
+ switch (_response.error.reason) {
13838
+ case "non-json":
13839
+ throw new LangfuseAPIError({
13840
+ statusCode: _response.error.statusCode,
13841
+ body: _response.error.rawBody,
13842
+ rawResponse: _response.rawResponse
13843
+ });
13844
+ case "timeout":
13845
+ throw new LangfuseAPITimeoutError(
13846
+ "Timeout exceeded when calling POST /api/public/unstable/evaluators."
13847
+ );
13848
+ case "unknown":
13849
+ throw new LangfuseAPIError({
13850
+ message: _response.error.errorMessage,
13851
+ rawResponse: _response.rawResponse
13852
+ });
13853
+ }
13854
+ }
13855
+ /**
13856
+ * List the evaluators available to the authenticated project.
13857
+ *
13858
+ * Important behavior:
13859
+ * - This endpoint returns the latest version of each available evaluator.
13860
+ * - Results can include evaluators from your project and Langfuse-managed evaluators.
13861
+ * - If the same evaluator name exists in both places, both are returned as separate items with different `scope` values.
13862
+ *
13863
+ * @param {LangfuseAPI.unstable.ListEvaluatorsRequest} request
13864
+ * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
13865
+ *
13866
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13867
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13868
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13869
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13870
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13871
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13872
+ * @throws {@link LangfuseAPI.Error}
13873
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13874
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13875
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13876
+ * @throws {@link LangfuseAPI.NotFoundError}
13877
+ *
13878
+ * @example
13879
+ * await client.unstable.evaluators.list()
13880
+ */
13881
+ list(request = {}, requestOptions) {
13882
+ return HttpResponsePromise.fromPromise(
13883
+ this.__list(request, requestOptions)
13884
+ );
13885
+ }
13886
+ async __list(request = {}, requestOptions) {
13887
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13888
+ const { page, limit } = request;
13889
+ const _queryParams = {};
13890
+ if (page != null) {
13891
+ _queryParams["page"] = page.toString();
13892
+ }
13893
+ if (limit != null) {
13894
+ _queryParams["limit"] = limit.toString();
13895
+ }
13896
+ let _headers = mergeHeaders(
13897
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13898
+ mergeOnlyDefinedHeaders({
13899
+ Authorization: await this._getAuthorizationHeader(),
13900
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13901
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13902
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13903
+ }),
13904
+ requestOptions == null ? void 0 : requestOptions.headers
13905
+ );
13906
+ const _response = await fetcher({
13907
+ url: url_exports.join(
13908
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13909
+ "/api/public/unstable/evaluators"
13910
+ ),
13911
+ method: "GET",
13912
+ headers: _headers,
13913
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
13914
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13915
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13916
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13917
+ });
13918
+ if (_response.ok) {
13919
+ return {
13920
+ data: _response.body,
13921
+ rawResponse: _response.rawResponse
13922
+ };
13923
+ }
13924
+ if (_response.error.reason === "status-code") {
13925
+ switch (_response.error.statusCode) {
13926
+ case 400:
13927
+ throw new unstable_exports.BadRequestError(
13928
+ _response.error.body,
13929
+ _response.rawResponse
13930
+ );
13931
+ case 401:
13932
+ throw new unstable_exports.UnauthorizedError(
13933
+ _response.error.body,
13934
+ _response.rawResponse
13935
+ );
13936
+ case 403:
13937
+ throw new unstable_exports.AccessDeniedError(
13938
+ _response.error.body,
13939
+ _response.rawResponse
13940
+ );
13941
+ case 405:
13942
+ throw new unstable_exports.MethodNotAllowedError(
13943
+ _response.error.body,
13944
+ _response.rawResponse
13945
+ );
13946
+ case 429:
13947
+ throw new unstable_exports.TooManyRequestsError(
13948
+ _response.error.body,
13949
+ _response.rawResponse
13950
+ );
13951
+ case 500:
13952
+ throw new unstable_exports.InternalServerError(
13953
+ _response.error.body,
13954
+ _response.rawResponse
13955
+ );
13956
+ case 400:
13957
+ throw new Error2(
13958
+ _response.error.body,
13959
+ _response.rawResponse
13960
+ );
13961
+ case 401:
13962
+ throw new UnauthorizedError(
13963
+ _response.error.body,
13964
+ _response.rawResponse
13965
+ );
13966
+ case 403:
13967
+ throw new AccessDeniedError(
13968
+ _response.error.body,
13969
+ _response.rawResponse
13970
+ );
13971
+ case 405:
13972
+ throw new MethodNotAllowedError(
13973
+ _response.error.body,
13974
+ _response.rawResponse
13975
+ );
13976
+ case 404:
13977
+ throw new NotFoundError(
13978
+ _response.error.body,
13979
+ _response.rawResponse
13980
+ );
13981
+ default:
13982
+ throw new LangfuseAPIError({
13983
+ statusCode: _response.error.statusCode,
13984
+ body: _response.error.body,
13985
+ rawResponse: _response.rawResponse
13986
+ });
13987
+ }
13988
+ }
13989
+ switch (_response.error.reason) {
13990
+ case "non-json":
13991
+ throw new LangfuseAPIError({
13992
+ statusCode: _response.error.statusCode,
13993
+ body: _response.error.rawBody,
13994
+ rawResponse: _response.rawResponse
13995
+ });
13996
+ case "timeout":
13997
+ throw new LangfuseAPITimeoutError(
13998
+ "Timeout exceeded when calling GET /api/public/unstable/evaluators."
13999
+ );
14000
+ case "unknown":
14001
+ throw new LangfuseAPIError({
14002
+ message: _response.error.errorMessage,
14003
+ rawResponse: _response.rawResponse
14004
+ });
14005
+ }
14006
+ }
14007
+ /**
14008
+ * Get one evaluator by `id`.
14009
+ *
14010
+ * 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.
14011
+ *
14012
+ * @param {string} evaluatorId - Evaluator identifier returned by the evaluator endpoints.
14013
+ * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
14014
+ *
14015
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
14016
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
14017
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
14018
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
14019
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
14020
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
14021
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
14022
+ * @throws {@link LangfuseAPI.Error}
14023
+ * @throws {@link LangfuseAPI.UnauthorizedError}
14024
+ * @throws {@link LangfuseAPI.AccessDeniedError}
14025
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
14026
+ * @throws {@link LangfuseAPI.NotFoundError}
14027
+ *
14028
+ * @example
14029
+ * await client.unstable.evaluators.get("evaluatorId")
14030
+ */
14031
+ get(evaluatorId, requestOptions) {
14032
+ return HttpResponsePromise.fromPromise(
14033
+ this.__get(evaluatorId, requestOptions)
14034
+ );
14035
+ }
14036
+ async __get(evaluatorId, requestOptions) {
14037
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
14038
+ let _headers = mergeHeaders(
14039
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
14040
+ mergeOnlyDefinedHeaders({
14041
+ Authorization: await this._getAuthorizationHeader(),
14042
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
14043
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
14044
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
14045
+ }),
14046
+ requestOptions == null ? void 0 : requestOptions.headers
14047
+ );
14048
+ const _response = await fetcher({
14049
+ url: url_exports.join(
14050
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
14051
+ `/api/public/unstable/evaluators/${encodeURIComponent(evaluatorId)}`
14052
+ ),
14053
+ method: "GET",
14054
+ headers: _headers,
14055
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
14056
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
14057
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
14058
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
14059
+ });
14060
+ if (_response.ok) {
14061
+ return {
14062
+ data: _response.body,
14063
+ rawResponse: _response.rawResponse
14064
+ };
14065
+ }
14066
+ if (_response.error.reason === "status-code") {
14067
+ switch (_response.error.statusCode) {
14068
+ case 400:
14069
+ throw new unstable_exports.BadRequestError(
14070
+ _response.error.body,
14071
+ _response.rawResponse
14072
+ );
14073
+ case 401:
14074
+ throw new unstable_exports.UnauthorizedError(
14075
+ _response.error.body,
14076
+ _response.rawResponse
14077
+ );
14078
+ case 403:
14079
+ throw new unstable_exports.AccessDeniedError(
14080
+ _response.error.body,
14081
+ _response.rawResponse
14082
+ );
14083
+ case 404:
14084
+ throw new unstable_exports.NotFoundError(
14085
+ _response.error.body,
14086
+ _response.rawResponse
14087
+ );
14088
+ case 405:
14089
+ throw new unstable_exports.MethodNotAllowedError(
14090
+ _response.error.body,
14091
+ _response.rawResponse
14092
+ );
14093
+ case 429:
14094
+ throw new unstable_exports.TooManyRequestsError(
14095
+ _response.error.body,
14096
+ _response.rawResponse
14097
+ );
14098
+ case 500:
14099
+ throw new unstable_exports.InternalServerError(
14100
+ _response.error.body,
14101
+ _response.rawResponse
14102
+ );
14103
+ case 400:
14104
+ throw new Error2(
14105
+ _response.error.body,
14106
+ _response.rawResponse
14107
+ );
14108
+ case 401:
14109
+ throw new UnauthorizedError(
14110
+ _response.error.body,
14111
+ _response.rawResponse
14112
+ );
14113
+ case 403:
14114
+ throw new AccessDeniedError(
14115
+ _response.error.body,
14116
+ _response.rawResponse
14117
+ );
14118
+ case 405:
14119
+ throw new MethodNotAllowedError(
14120
+ _response.error.body,
14121
+ _response.rawResponse
14122
+ );
14123
+ case 404:
14124
+ throw new NotFoundError(
14125
+ _response.error.body,
14126
+ _response.rawResponse
14127
+ );
14128
+ default:
14129
+ throw new LangfuseAPIError({
14130
+ statusCode: _response.error.statusCode,
14131
+ body: _response.error.body,
14132
+ rawResponse: _response.rawResponse
14133
+ });
14134
+ }
14135
+ }
14136
+ switch (_response.error.reason) {
14137
+ case "non-json":
14138
+ throw new LangfuseAPIError({
14139
+ statusCode: _response.error.statusCode,
14140
+ body: _response.error.rawBody,
14141
+ rawResponse: _response.rawResponse
14142
+ });
14143
+ case "timeout":
14144
+ throw new LangfuseAPITimeoutError(
14145
+ "Timeout exceeded when calling GET /api/public/unstable/evaluators/{evaluatorId}."
14146
+ );
14147
+ case "unknown":
14148
+ throw new LangfuseAPIError({
14149
+ message: _response.error.errorMessage,
14150
+ rawResponse: _response.rawResponse
14151
+ });
14152
+ }
14153
+ }
14154
+ async _getAuthorizationHeader() {
14155
+ const username = await Supplier.get(this._options.username);
14156
+ const password = await Supplier.get(this._options.password);
14157
+ if (username != null && password != null) {
14158
+ return BasicAuth.toAuthorizationHeader({
14159
+ username,
14160
+ password
14161
+ });
14162
+ }
14163
+ return void 0;
14164
+ }
14165
+ };
14166
+
14167
+ // src/api/api/resources/unstable/client/Client.ts
14168
+ var Unstable = class {
14169
+ constructor(_options) {
14170
+ this._options = _options;
14171
+ }
14172
+ get evaluationRules() {
14173
+ var _a2;
14174
+ return (_a2 = this._evaluationRules) != null ? _a2 : this._evaluationRules = new EvaluationRules(this._options);
14175
+ }
14176
+ get evaluators() {
14177
+ var _a2;
14178
+ return (_a2 = this._evaluators) != null ? _a2 : this._evaluators = new Evaluators(this._options);
14179
+ }
14180
+ };
14181
+
14182
+ // src/api/Client.ts
14183
+ var LangfuseAPIClient = class {
14184
+ constructor(_options) {
14185
+ this._options = {
14186
+ ..._options,
14187
+ headers: mergeHeaders(
14188
+ {
14189
+ "X-Langfuse-Sdk-Name": _options == null ? void 0 : _options.xLangfuseSdkName,
14190
+ "X-Langfuse-Sdk-Version": _options == null ? void 0 : _options.xLangfuseSdkVersion,
14191
+ "X-Langfuse-Public-Key": _options == null ? void 0 : _options.xLangfusePublicKey
14192
+ },
14193
+ _options == null ? void 0 : _options.headers
14194
+ )
14195
+ };
14196
+ }
14197
+ get annotationQueues() {
14198
+ var _a2;
14199
+ return (_a2 = this._annotationQueues) != null ? _a2 : this._annotationQueues = new AnnotationQueues(this._options);
14200
+ }
14201
+ get blobStorageIntegrations() {
14202
+ var _a2;
14203
+ return (_a2 = this._blobStorageIntegrations) != null ? _a2 : this._blobStorageIntegrations = new BlobStorageIntegrations(
14204
+ this._options
14205
+ );
14206
+ }
14207
+ get comments() {
14208
+ var _a2;
14209
+ return (_a2 = this._comments) != null ? _a2 : this._comments = new Comments(this._options);
14210
+ }
14211
+ get datasetItems() {
14212
+ var _a2;
14213
+ return (_a2 = this._datasetItems) != null ? _a2 : this._datasetItems = new DatasetItems(this._options);
14214
+ }
14215
+ get datasetRunItems() {
14216
+ var _a2;
12094
14217
  return (_a2 = this._datasetRunItems) != null ? _a2 : this._datasetRunItems = new DatasetRunItems(this._options);
12095
14218
  }
12096
14219
  get datasets() {
@@ -12157,6 +14280,10 @@ var LangfuseAPIClient = class {
12157
14280
  var _a2;
12158
14281
  return (_a2 = this._scoreConfigs) != null ? _a2 : this._scoreConfigs = new ScoreConfigs(this._options);
12159
14282
  }
14283
+ get scoresV3() {
14284
+ var _a2;
14285
+ return (_a2 = this._scoresV3) != null ? _a2 : this._scoresV3 = new ScoresV3(this._options);
14286
+ }
12160
14287
  get scores() {
12161
14288
  var _a2;
12162
14289
  return (_a2 = this._scores) != null ? _a2 : this._scores = new Scores(this._options);
@@ -12169,6 +14296,10 @@ var LangfuseAPIClient = class {
12169
14296
  var _a2;
12170
14297
  return (_a2 = this._trace) != null ? _a2 : this._trace = new Trace(this._options);
12171
14298
  }
14299
+ get unstable() {
14300
+ var _a2;
14301
+ return (_a2 = this._unstable) != null ? _a2 : this._unstable = new Unstable(this._options);
14302
+ }
12172
14303
  };
12173
14304
 
12174
14305
  // src/media.ts
@@ -12756,8 +14887,10 @@ export {
12756
14887
  AccessDeniedError,
12757
14888
  AnnotationQueueObjectType,
12758
14889
  AnnotationQueueStatus,
14890
+ BlobStorageExportFieldGroup,
12759
14891
  BlobStorageExportFrequency,
12760
14892
  BlobStorageExportMode,
14893
+ BlobStorageExportSource,
12761
14894
  BlobStorageIntegrationFileType,
12762
14895
  BlobStorageIntegrationType,
12763
14896
  BlobStorageSyncStatus,
@@ -12836,10 +14969,12 @@ export {
12836
14969
  scim_exports as scim,
12837
14970
  scoreConfigs_exports as scoreConfigs,
12838
14971
  scores_exports as scores,
14972
+ scoresV3_exports as scoresV3,
12839
14973
  serializeValue,
12840
14974
  sessions_exports as sessions,
12841
14975
  setLangfuseTraceIdInBaggage,
12842
14976
  trace_exports as trace,
14977
+ unstable_exports as unstable,
12843
14978
  utils_exports as utils
12844
14979
  };
12845
14980
  //# sourceMappingURL=index.mjs.map