@langfuse/core 5.4.0-beta.1 → 5.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -23,8 +23,10 @@ __export(index_exports, {
23
23
  AccessDeniedError: () => AccessDeniedError,
24
24
  AnnotationQueueObjectType: () => AnnotationQueueObjectType,
25
25
  AnnotationQueueStatus: () => AnnotationQueueStatus,
26
+ BlobStorageExportFieldGroup: () => BlobStorageExportFieldGroup,
26
27
  BlobStorageExportFrequency: () => BlobStorageExportFrequency,
27
28
  BlobStorageExportMode: () => BlobStorageExportMode,
29
+ BlobStorageExportSource: () => BlobStorageExportSource,
28
30
  BlobStorageIntegrationFileType: () => BlobStorageIntegrationFileType,
29
31
  BlobStorageIntegrationType: () => BlobStorageIntegrationType,
30
32
  BlobStorageSyncStatus: () => BlobStorageSyncStatus,
@@ -107,6 +109,7 @@ __export(index_exports, {
107
109
  sessions: () => sessions_exports,
108
110
  setLangfuseTraceIdInBaggage: () => setLangfuseTraceIdInBaggage,
109
111
  trace: () => trace_exports,
112
+ unstable: () => unstable_exports,
110
113
  utils: () => utils_exports
111
114
  });
112
115
  module.exports = __toCommonJS(index_exports);
@@ -383,7 +386,7 @@ var resetGlobalLogger = () => {
383
386
  // package.json
384
387
  var package_default = {
385
388
  name: "@langfuse/core",
386
- version: "5.4.0-beta.1",
389
+ version: "5.4.1",
387
390
  description: "Core functions and utilities for Langfuse packages",
388
391
  type: "module",
389
392
  sideEffects: false,
@@ -492,8 +495,10 @@ var AnnotationQueueObjectType = {
492
495
  // src/api/api/resources/blobStorageIntegrations/index.ts
493
496
  var blobStorageIntegrations_exports = {};
494
497
  __export(blobStorageIntegrations_exports, {
498
+ BlobStorageExportFieldGroup: () => BlobStorageExportFieldGroup,
495
499
  BlobStorageExportFrequency: () => BlobStorageExportFrequency,
496
500
  BlobStorageExportMode: () => BlobStorageExportMode,
501
+ BlobStorageExportSource: () => BlobStorageExportSource,
497
502
  BlobStorageIntegrationFileType: () => BlobStorageIntegrationFileType,
498
503
  BlobStorageIntegrationType: () => BlobStorageIntegrationType,
499
504
  BlobStorageSyncStatus: () => BlobStorageSyncStatus
@@ -522,11 +527,34 @@ var BlobStorageExportMode = {
522
527
 
523
528
  // src/api/api/resources/blobStorageIntegrations/types/BlobStorageExportFrequency.ts
524
529
  var BlobStorageExportFrequency = {
530
+ Every20Minutes: "every_20_minutes",
525
531
  Hourly: "hourly",
526
532
  Daily: "daily",
527
533
  Weekly: "weekly"
528
534
  };
529
535
 
536
+ // src/api/api/resources/blobStorageIntegrations/types/BlobStorageExportSource.ts
537
+ var BlobStorageExportSource = {
538
+ LegacyTracesObservations: "LEGACY_TRACES_OBSERVATIONS",
539
+ ObservationsV2: "OBSERVATIONS_V2",
540
+ LegacyTracesAndEnrichedObservations: "LEGACY_TRACES_AND_ENRICHED_OBSERVATIONS"
541
+ };
542
+
543
+ // src/api/api/resources/blobStorageIntegrations/types/BlobStorageExportFieldGroup.ts
544
+ var BlobStorageExportFieldGroup = {
545
+ Core: "core",
546
+ Basic: "basic",
547
+ Time: "time",
548
+ Io: "io",
549
+ Metadata: "metadata",
550
+ Model: "model",
551
+ Usage: "usage",
552
+ Prompt: "prompt",
553
+ Metrics: "metrics",
554
+ Tools: "tools",
555
+ TraceContext: "trace_context"
556
+ };
557
+
530
558
  // src/api/api/resources/blobStorageIntegrations/types/BlobStorageSyncStatus.ts
531
559
  var BlobStorageSyncStatus = {
532
560
  Idle: "idle",
@@ -787,6 +815,7 @@ var ObservationType = {
787
815
  // src/api/api/resources/legacy/index.ts
788
816
  var legacy_exports = {};
789
817
  __export(legacy_exports, {
818
+ CreateScoreSource: () => CreateScoreSource,
790
819
  metricsV1: () => metricsV1_exports,
791
820
  observationsV1: () => observationsV1_exports,
792
821
  scoreV1: () => scoreV1_exports
@@ -800,6 +829,15 @@ var observationsV1_exports = {};
800
829
 
801
830
  // src/api/api/resources/legacy/resources/scoreV1/index.ts
802
831
  var scoreV1_exports = {};
832
+ __export(scoreV1_exports, {
833
+ CreateScoreSource: () => CreateScoreSource
834
+ });
835
+
836
+ // src/api/api/resources/legacy/resources/scoreV1/types/CreateScoreSource.ts
837
+ var CreateScoreSource = {
838
+ Api: "API",
839
+ Annotation: "ANNOTATION"
840
+ };
803
841
 
804
842
  // src/api/api/resources/llmConnections/index.ts
805
843
  var llmConnections_exports = {};
@@ -959,6 +997,297 @@ var sessions_exports = {};
959
997
  // src/api/api/resources/trace/index.ts
960
998
  var trace_exports = {};
961
999
 
1000
+ // src/api/api/resources/unstable/index.ts
1001
+ var unstable_exports = {};
1002
+ __export(unstable_exports, {
1003
+ AccessDeniedError: () => AccessDeniedError2,
1004
+ BadRequestError: () => BadRequestError,
1005
+ ConflictError: () => ConflictError,
1006
+ EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator,
1007
+ EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator,
1008
+ EvaluationRuleMappingSource: () => EvaluationRuleMappingSource,
1009
+ EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator,
1010
+ EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator,
1011
+ EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator,
1012
+ EvaluationRuleStatus: () => EvaluationRuleStatus,
1013
+ EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator,
1014
+ EvaluationRuleTarget: () => EvaluationRuleTarget,
1015
+ EvaluatorOutputDataType: () => EvaluatorOutputDataType,
1016
+ EvaluatorScope: () => EvaluatorScope,
1017
+ EvaluatorType: () => EvaluatorType,
1018
+ InternalServerError: () => InternalServerError,
1019
+ MethodNotAllowedError: () => MethodNotAllowedError2,
1020
+ NotFoundError: () => NotFoundError2,
1021
+ PublicApiErrorCode: () => PublicApiErrorCode,
1022
+ TooManyRequestsError: () => TooManyRequestsError,
1023
+ UnauthorizedError: () => UnauthorizedError2,
1024
+ UnprocessableContentError: () => UnprocessableContentError,
1025
+ commons: () => commons_exports2,
1026
+ errors: () => errors_exports2,
1027
+ evaluationRules: () => evaluationRules_exports,
1028
+ evaluators: () => evaluators_exports
1029
+ });
1030
+
1031
+ // src/api/api/resources/unstable/resources/commons/index.ts
1032
+ var commons_exports2 = {};
1033
+ __export(commons_exports2, {
1034
+ EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator,
1035
+ EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator,
1036
+ EvaluationRuleMappingSource: () => EvaluationRuleMappingSource,
1037
+ EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator,
1038
+ EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator,
1039
+ EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator,
1040
+ EvaluationRuleStatus: () => EvaluationRuleStatus,
1041
+ EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator,
1042
+ EvaluationRuleTarget: () => EvaluationRuleTarget,
1043
+ EvaluatorOutputDataType: () => EvaluatorOutputDataType,
1044
+ EvaluatorScope: () => EvaluatorScope,
1045
+ EvaluatorType: () => EvaluatorType
1046
+ });
1047
+
1048
+ // src/api/api/resources/unstable/resources/commons/types/EvaluatorType.ts
1049
+ var EvaluatorType = {
1050
+ LlmAsJudge: "llm_as_judge"
1051
+ };
1052
+
1053
+ // src/api/api/resources/unstable/resources/commons/types/EvaluatorScope.ts
1054
+ var EvaluatorScope = {
1055
+ Project: "project",
1056
+ Managed: "managed"
1057
+ };
1058
+
1059
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleTarget.ts
1060
+ var EvaluationRuleTarget = {
1061
+ Observation: "observation",
1062
+ Experiment: "experiment"
1063
+ };
1064
+
1065
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStatus.ts
1066
+ var EvaluationRuleStatus = {
1067
+ Active: "active",
1068
+ Inactive: "inactive",
1069
+ Paused: "paused"
1070
+ };
1071
+
1072
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleMappingSource.ts
1073
+ var EvaluationRuleMappingSource = {
1074
+ Input: "input",
1075
+ Output: "output",
1076
+ Metadata: "metadata",
1077
+ ExpectedOutput: "expected_output",
1078
+ ExperimentItemMetadata: "experiment_item_metadata"
1079
+ };
1080
+
1081
+ // src/api/api/resources/unstable/resources/commons/types/EvaluatorOutputDataType.ts
1082
+ var EvaluatorOutputDataType = {
1083
+ Numeric: "NUMERIC",
1084
+ Boolean: "BOOLEAN",
1085
+ Categorical: "CATEGORICAL"
1086
+ };
1087
+
1088
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStringFilterOperator.ts
1089
+ var EvaluationRuleStringFilterOperator = {
1090
+ Equals: "=",
1091
+ Contains: "contains",
1092
+ DoesNotContain: "does not contain",
1093
+ StartsWith: "starts with",
1094
+ EndsWith: "ends with"
1095
+ };
1096
+
1097
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNumberFilterOperator.ts
1098
+ var EvaluationRuleNumberFilterOperator = {
1099
+ Equals: "=",
1100
+ GreaterThan: ">",
1101
+ LessThan: "<",
1102
+ GreaterThanOrEqual: ">=",
1103
+ LessThanOrEqual: "<="
1104
+ };
1105
+
1106
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleOptionsFilterOperator.ts
1107
+ var EvaluationRuleOptionsFilterOperator = {
1108
+ AnyOf: "any of",
1109
+ NoneOf: "none of"
1110
+ };
1111
+
1112
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleArrayOptionsFilterOperator.ts
1113
+ var EvaluationRuleArrayOptionsFilterOperator = {
1114
+ AnyOf: "any of",
1115
+ NoneOf: "none of",
1116
+ AllOf: "all of"
1117
+ };
1118
+
1119
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleBooleanFilterOperator.ts
1120
+ var EvaluationRuleBooleanFilterOperator = {
1121
+ Equals: "=",
1122
+ NotEquals: "<>"
1123
+ };
1124
+
1125
+ // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNullFilterOperator.ts
1126
+ var EvaluationRuleNullFilterOperator = {
1127
+ IsNull: "is null",
1128
+ IsNotNull: "is not null"
1129
+ };
1130
+
1131
+ // src/api/api/resources/unstable/resources/errors/index.ts
1132
+ var errors_exports2 = {};
1133
+ __export(errors_exports2, {
1134
+ AccessDeniedError: () => AccessDeniedError2,
1135
+ BadRequestError: () => BadRequestError,
1136
+ ConflictError: () => ConflictError,
1137
+ InternalServerError: () => InternalServerError,
1138
+ MethodNotAllowedError: () => MethodNotAllowedError2,
1139
+ NotFoundError: () => NotFoundError2,
1140
+ PublicApiErrorCode: () => PublicApiErrorCode,
1141
+ TooManyRequestsError: () => TooManyRequestsError,
1142
+ UnauthorizedError: () => UnauthorizedError2,
1143
+ UnprocessableContentError: () => UnprocessableContentError
1144
+ });
1145
+
1146
+ // src/api/api/resources/unstable/resources/errors/types/PublicApiErrorCode.ts
1147
+ var PublicApiErrorCode = {
1148
+ AuthenticationFailed: "authentication_failed",
1149
+ AccessDenied: "access_denied",
1150
+ InvalidRequest: "invalid_request",
1151
+ InvalidQuery: "invalid_query",
1152
+ InvalidBody: "invalid_body",
1153
+ InvalidFilterValue: "invalid_filter_value",
1154
+ InvalidJsonPath: "invalid_json_path",
1155
+ InvalidVariableMapping: "invalid_variable_mapping",
1156
+ MissingVariableMapping: "missing_variable_mapping",
1157
+ DuplicateVariableMapping: "duplicate_variable_mapping",
1158
+ ResourceNotFound: "resource_not_found",
1159
+ NameConflict: "name_conflict",
1160
+ EvaluatorPreflightFailed: "evaluator_preflight_failed",
1161
+ Conflict: "conflict",
1162
+ UnprocessableContent: "unprocessable_content",
1163
+ RateLimited: "rate_limited",
1164
+ MethodNotAllowed: "method_not_allowed",
1165
+ InternalError: "internal_error"
1166
+ };
1167
+
1168
+ // src/api/api/resources/unstable/resources/errors/errors/BadRequestError.ts
1169
+ var BadRequestError = class _BadRequestError extends LangfuseAPIError {
1170
+ constructor(body, rawResponse) {
1171
+ super({
1172
+ message: "BadRequestError",
1173
+ statusCode: 400,
1174
+ body,
1175
+ rawResponse
1176
+ });
1177
+ Object.setPrototypeOf(this, _BadRequestError.prototype);
1178
+ }
1179
+ };
1180
+
1181
+ // src/api/api/resources/unstable/resources/errors/errors/UnauthorizedError.ts
1182
+ var UnauthorizedError2 = class _UnauthorizedError extends LangfuseAPIError {
1183
+ constructor(body, rawResponse) {
1184
+ super({
1185
+ message: "UnauthorizedError",
1186
+ statusCode: 401,
1187
+ body,
1188
+ rawResponse
1189
+ });
1190
+ Object.setPrototypeOf(this, _UnauthorizedError.prototype);
1191
+ }
1192
+ };
1193
+
1194
+ // src/api/api/resources/unstable/resources/errors/errors/AccessDeniedError.ts
1195
+ var AccessDeniedError2 = class _AccessDeniedError extends LangfuseAPIError {
1196
+ constructor(body, rawResponse) {
1197
+ super({
1198
+ message: "AccessDeniedError",
1199
+ statusCode: 403,
1200
+ body,
1201
+ rawResponse
1202
+ });
1203
+ Object.setPrototypeOf(this, _AccessDeniedError.prototype);
1204
+ }
1205
+ };
1206
+
1207
+ // src/api/api/resources/unstable/resources/errors/errors/NotFoundError.ts
1208
+ var NotFoundError2 = class _NotFoundError extends LangfuseAPIError {
1209
+ constructor(body, rawResponse) {
1210
+ super({
1211
+ message: "NotFoundError",
1212
+ statusCode: 404,
1213
+ body,
1214
+ rawResponse
1215
+ });
1216
+ Object.setPrototypeOf(this, _NotFoundError.prototype);
1217
+ }
1218
+ };
1219
+
1220
+ // src/api/api/resources/unstable/resources/errors/errors/MethodNotAllowedError.ts
1221
+ var MethodNotAllowedError2 = class _MethodNotAllowedError extends LangfuseAPIError {
1222
+ constructor(body, rawResponse) {
1223
+ super({
1224
+ message: "MethodNotAllowedError",
1225
+ statusCode: 405,
1226
+ body,
1227
+ rawResponse
1228
+ });
1229
+ Object.setPrototypeOf(this, _MethodNotAllowedError.prototype);
1230
+ }
1231
+ };
1232
+
1233
+ // src/api/api/resources/unstable/resources/errors/errors/ConflictError.ts
1234
+ var ConflictError = class _ConflictError extends LangfuseAPIError {
1235
+ constructor(body, rawResponse) {
1236
+ super({
1237
+ message: "ConflictError",
1238
+ statusCode: 409,
1239
+ body,
1240
+ rawResponse
1241
+ });
1242
+ Object.setPrototypeOf(this, _ConflictError.prototype);
1243
+ }
1244
+ };
1245
+
1246
+ // src/api/api/resources/unstable/resources/errors/errors/UnprocessableContentError.ts
1247
+ var UnprocessableContentError = class _UnprocessableContentError extends LangfuseAPIError {
1248
+ constructor(body, rawResponse) {
1249
+ super({
1250
+ message: "UnprocessableContentError",
1251
+ statusCode: 422,
1252
+ body,
1253
+ rawResponse
1254
+ });
1255
+ Object.setPrototypeOf(this, _UnprocessableContentError.prototype);
1256
+ }
1257
+ };
1258
+
1259
+ // src/api/api/resources/unstable/resources/errors/errors/TooManyRequestsError.ts
1260
+ var TooManyRequestsError = class _TooManyRequestsError extends LangfuseAPIError {
1261
+ constructor(body, rawResponse) {
1262
+ super({
1263
+ message: "TooManyRequestsError",
1264
+ statusCode: 429,
1265
+ body,
1266
+ rawResponse
1267
+ });
1268
+ Object.setPrototypeOf(this, _TooManyRequestsError.prototype);
1269
+ }
1270
+ };
1271
+
1272
+ // src/api/api/resources/unstable/resources/errors/errors/InternalServerError.ts
1273
+ var InternalServerError = class _InternalServerError extends LangfuseAPIError {
1274
+ constructor(body, rawResponse) {
1275
+ super({
1276
+ message: "InternalServerError",
1277
+ statusCode: 500,
1278
+ body,
1279
+ rawResponse
1280
+ });
1281
+ Object.setPrototypeOf(this, _InternalServerError.prototype);
1282
+ }
1283
+ };
1284
+
1285
+ // src/api/api/resources/unstable/resources/evaluationRules/index.ts
1286
+ var evaluationRules_exports = {};
1287
+
1288
+ // src/api/api/resources/unstable/resources/evaluators/index.ts
1289
+ var evaluators_exports = {};
1290
+
962
1291
  // src/api/api/resources/utils/index.ts
963
1292
  var utils_exports = {};
964
1293
  __export(utils_exports, {
@@ -2944,13 +3273,15 @@ var BlobStorageIntegrations = class {
2944
3273
  * accessKeyId: undefined,
2945
3274
  * secretAccessKey: undefined,
2946
3275
  * prefix: undefined,
2947
- * exportFrequency: "hourly",
3276
+ * exportFrequency: "every_20_minutes",
2948
3277
  * enabled: true,
2949
3278
  * forcePathStyle: true,
2950
3279
  * fileType: "JSON",
2951
3280
  * exportMode: "FULL_HISTORY",
2952
3281
  * exportStartDate: undefined,
2953
- * compressed: undefined
3282
+ * compressed: undefined,
3283
+ * exportSource: undefined,
3284
+ * exportFieldGroups: undefined
2954
3285
  * })
2955
3286
  */
2956
3287
  upsertBlobStorageIntegration(request, requestOptions) {
@@ -5754,7 +6085,8 @@ var ScoreV1 = class {
5754
6085
  * environment: undefined,
5755
6086
  * queueId: undefined,
5756
6087
  * dataType: undefined,
5757
- * configId: undefined
6088
+ * configId: undefined,
6089
+ * source: undefined
5758
6090
  * })
5759
6091
  */
5760
6092
  create(request, requestOptions) {
@@ -6211,6 +6543,109 @@ var LlmConnections = class {
6211
6543
  });
6212
6544
  }
6213
6545
  }
6546
+ /**
6547
+ * Delete an LLM connection by id. Evaluators that depend on the deleted connection are automatically paused.
6548
+ *
6549
+ * @param {string} id
6550
+ * @param {LlmConnections.RequestOptions} requestOptions - Request-specific configuration.
6551
+ *
6552
+ * @throws {@link LangfuseAPI.Error}
6553
+ * @throws {@link LangfuseAPI.UnauthorizedError}
6554
+ * @throws {@link LangfuseAPI.AccessDeniedError}
6555
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
6556
+ * @throws {@link LangfuseAPI.NotFoundError}
6557
+ *
6558
+ * @example
6559
+ * await client.llmConnections.delete("id")
6560
+ */
6561
+ delete(id, requestOptions) {
6562
+ return HttpResponsePromise.fromPromise(
6563
+ this.__delete(id, requestOptions)
6564
+ );
6565
+ }
6566
+ async __delete(id, requestOptions) {
6567
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
6568
+ let _headers = mergeHeaders(
6569
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
6570
+ mergeOnlyDefinedHeaders({
6571
+ Authorization: await this._getAuthorizationHeader(),
6572
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
6573
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
6574
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
6575
+ }),
6576
+ requestOptions == null ? void 0 : requestOptions.headers
6577
+ );
6578
+ const _response = await fetcher({
6579
+ url: url_exports.join(
6580
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
6581
+ `/api/public/llm-connections/${encodeURIComponent(id)}`
6582
+ ),
6583
+ method: "DELETE",
6584
+ headers: _headers,
6585
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
6586
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
6587
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
6588
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
6589
+ });
6590
+ if (_response.ok) {
6591
+ return {
6592
+ data: _response.body,
6593
+ rawResponse: _response.rawResponse
6594
+ };
6595
+ }
6596
+ if (_response.error.reason === "status-code") {
6597
+ switch (_response.error.statusCode) {
6598
+ case 400:
6599
+ throw new Error2(
6600
+ _response.error.body,
6601
+ _response.rawResponse
6602
+ );
6603
+ case 401:
6604
+ throw new UnauthorizedError(
6605
+ _response.error.body,
6606
+ _response.rawResponse
6607
+ );
6608
+ case 403:
6609
+ throw new AccessDeniedError(
6610
+ _response.error.body,
6611
+ _response.rawResponse
6612
+ );
6613
+ case 405:
6614
+ throw new MethodNotAllowedError(
6615
+ _response.error.body,
6616
+ _response.rawResponse
6617
+ );
6618
+ case 404:
6619
+ throw new NotFoundError(
6620
+ _response.error.body,
6621
+ _response.rawResponse
6622
+ );
6623
+ default:
6624
+ throw new LangfuseAPIError({
6625
+ statusCode: _response.error.statusCode,
6626
+ body: _response.error.body,
6627
+ rawResponse: _response.rawResponse
6628
+ });
6629
+ }
6630
+ }
6631
+ switch (_response.error.reason) {
6632
+ case "non-json":
6633
+ throw new LangfuseAPIError({
6634
+ statusCode: _response.error.statusCode,
6635
+ body: _response.error.rawBody,
6636
+ rawResponse: _response.rawResponse
6637
+ });
6638
+ case "timeout":
6639
+ throw new LangfuseAPITimeoutError(
6640
+ "Timeout exceeded when calling DELETE /api/public/llm-connections/{id}."
6641
+ );
6642
+ case "unknown":
6643
+ throw new LangfuseAPIError({
6644
+ message: _response.error.errorMessage,
6645
+ rawResponse: _response.rawResponse
6646
+ });
6647
+ }
6648
+ }
6214
6649
  async _getAuthorizationHeader() {
6215
6650
  const username = await Supplier.get(this._options.username);
6216
6651
  const password = await Supplier.get(this._options.password);
@@ -7261,9 +7696,10 @@ var Observations = class {
7261
7696
  * - `io` - input, output
7262
7697
  * - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
7263
7698
  * - `model` - providedModelName, internalModelId, modelParameters
7264
- * - `usage` - usageDetails, costDetails, totalCost
7699
+ * - `usage` - usageDetails, costDetails, totalCost, usagePricingTierName
7265
7700
  * - `prompt` - promptId, promptName, promptVersion
7266
7701
  * - `metrics` - latency, timeToFirstToken
7702
+ * - `trace_context` - tags, release, traceName
7267
7703
  *
7268
7704
  * If not specified, `core` and `basic` field groups are returned.
7269
7705
  *
@@ -12163,34 +12599,1442 @@ var Trace = class {
12163
12599
  }
12164
12600
  };
12165
12601
 
12166
- // src/api/Client.ts
12167
- var LangfuseAPIClient = class {
12602
+ // src/api/api/resources/unstable/resources/evaluationRules/client/Client.ts
12603
+ var EvaluationRules = class {
12168
12604
  constructor(_options) {
12169
- this._options = {
12170
- ..._options,
12171
- headers: mergeHeaders(
12172
- {
12173
- "X-Langfuse-Sdk-Name": _options == null ? void 0 : _options.xLangfuseSdkName,
12174
- "X-Langfuse-Sdk-Version": _options == null ? void 0 : _options.xLangfuseSdkVersion,
12175
- "X-Langfuse-Public-Key": _options == null ? void 0 : _options.xLangfusePublicKey
12176
- },
12177
- _options == null ? void 0 : _options.headers
12178
- )
12179
- };
12180
- }
12181
- get annotationQueues() {
12182
- var _a2;
12183
- return (_a2 = this._annotationQueues) != null ? _a2 : this._annotationQueues = new AnnotationQueues(this._options);
12184
- }
12185
- get blobStorageIntegrations() {
12186
- var _a2;
12187
- return (_a2 = this._blobStorageIntegrations) != null ? _a2 : this._blobStorageIntegrations = new BlobStorageIntegrations(
12188
- this._options
12189
- );
12190
- }
12191
- get comments() {
12192
- var _a2;
12193
- return (_a2 = this._comments) != null ? _a2 : this._comments = new Comments(this._options);
12605
+ this._options = _options;
12606
+ }
12607
+ /**
12608
+ * Create an evaluation rule.
12609
+ *
12610
+ * An evaluation rule defines **what** incoming data should be evaluated and **how prompt variables should be populated** from that data.
12611
+ *
12612
+ * Use this resource after choosing an evaluator from the evaluator endpoints.
12613
+ *
12614
+ * Key rules:
12615
+ * - `name` must be unique within the project for public evaluation rules
12616
+ * - `target` must be `observation` or `experiment`
12617
+ * - `evaluator.name` + `evaluator.scope` must identify an existing evaluator family returned by the evaluator endpoints
12618
+ * - Langfuse resolves that family to its latest version before saving the evaluation rule
12619
+ * - for `target=experiment`, use dataset `id` values from `GET /api/public/v2/datasets` when filtering by `datasetId`
12620
+ * - every evaluator prompt variable must be mapped exactly once
12621
+ * - `expected_output` and `experiment_item_metadata` mappings are only valid for `target=experiment`
12622
+ * - if `enabled=true`, Langfuse validates that the referenced evaluator can currently run
12623
+ * - at most 50 evaluation rules can be effectively active in one project at the same time
12624
+ *
12625
+ * If an evaluation rule with the same `name` already exists in the project, the API returns `409`.
12626
+ * In that case, update the existing resource with `PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}` instead of creating a second one.
12627
+ *
12628
+ * If enabling this resource would exceed the 50-active limit, the API also returns `409`.
12629
+ * In that case, disable or pause another active evaluation rule before enabling a new one.
12630
+ *
12631
+ * Current scope:
12632
+ * - evaluation rules are live-ingestion rules only
12633
+ * - they do not trigger historical backfills
12634
+ *
12635
+ * Recovery guidance:
12636
+ * - `400 invalid_filter_value`: fix the filter `column` or `value` using `details.column`, `details.invalidValues`, and `details.allowedValues`
12637
+ * - `400 invalid_filter_value` with `details.column=datasetId`: call `GET /api/public/v2/datasets`, then retry with dataset `id` values from that response
12638
+ * - `400 missing_variable_mapping`: fetch the evaluator again and make sure every variable in `variables` appears exactly once in `mapping`
12639
+ * - `400 duplicate_variable_mapping`: remove repeated mappings for the same variable
12640
+ * - `400 invalid_variable_mapping`: switch to a valid `source` for the selected `target`, or fix the variable name
12641
+ * - `400 invalid_json_path`: remove or correct the `jsonPath`
12642
+ * - `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.
12643
+ *
12644
+ * @param {LangfuseAPI.unstable.CreateEvaluationRuleRequest} request
12645
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
12646
+ *
12647
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
12648
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
12649
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
12650
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
12651
+ * @throws {@link LangfuseAPI.unstable.ConflictError}
12652
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
12653
+ * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
12654
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
12655
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
12656
+ * @throws {@link LangfuseAPI.Error}
12657
+ * @throws {@link LangfuseAPI.UnauthorizedError}
12658
+ * @throws {@link LangfuseAPI.AccessDeniedError}
12659
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
12660
+ * @throws {@link LangfuseAPI.NotFoundError}
12661
+ *
12662
+ * @example
12663
+ * await client.unstable.evaluationRules.create({
12664
+ * name: "answer-correctness-live",
12665
+ * evaluator: {
12666
+ * name: "answer-correctness",
12667
+ * scope: "project"
12668
+ * },
12669
+ * target: "observation",
12670
+ * enabled: true,
12671
+ * sampling: 1,
12672
+ * filter: [{
12673
+ * type: "stringOptions",
12674
+ * column: "type",
12675
+ * operator: "any of",
12676
+ * value: ["GENERATION"]
12677
+ * }],
12678
+ * mapping: [{
12679
+ * variable: "input",
12680
+ * source: "input"
12681
+ * }, {
12682
+ * variable: "output",
12683
+ * source: "output"
12684
+ * }]
12685
+ * })
12686
+ *
12687
+ * @example
12688
+ * await client.unstable.evaluationRules.create({
12689
+ * name: "experiment-expected-output-match",
12690
+ * evaluator: {
12691
+ * name: "expected-output-match",
12692
+ * scope: "project"
12693
+ * },
12694
+ * target: "experiment",
12695
+ * enabled: true,
12696
+ * sampling: 0.5,
12697
+ * filter: [{
12698
+ * type: "stringOptions",
12699
+ * column: "datasetId",
12700
+ * operator: "any of",
12701
+ * value: ["550e8400-e29b-41d4-a716-446655440000"]
12702
+ * }],
12703
+ * mapping: [{
12704
+ * variable: "output",
12705
+ * source: "output"
12706
+ * }, {
12707
+ * variable: "expected_output",
12708
+ * source: "expected_output"
12709
+ * }]
12710
+ * })
12711
+ */
12712
+ create(request, requestOptions) {
12713
+ return HttpResponsePromise.fromPromise(
12714
+ this.__create(request, requestOptions)
12715
+ );
12716
+ }
12717
+ async __create(request, requestOptions) {
12718
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
12719
+ let _headers = mergeHeaders(
12720
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
12721
+ mergeOnlyDefinedHeaders({
12722
+ Authorization: await this._getAuthorizationHeader(),
12723
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
12724
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
12725
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
12726
+ }),
12727
+ requestOptions == null ? void 0 : requestOptions.headers
12728
+ );
12729
+ const _response = await fetcher({
12730
+ url: url_exports.join(
12731
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
12732
+ "/api/public/unstable/evaluation-rules"
12733
+ ),
12734
+ method: "POST",
12735
+ headers: _headers,
12736
+ contentType: "application/json",
12737
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
12738
+ requestType: "json",
12739
+ body: request,
12740
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
12741
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
12742
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
12743
+ });
12744
+ if (_response.ok) {
12745
+ return {
12746
+ data: _response.body,
12747
+ rawResponse: _response.rawResponse
12748
+ };
12749
+ }
12750
+ if (_response.error.reason === "status-code") {
12751
+ switch (_response.error.statusCode) {
12752
+ case 400:
12753
+ throw new unstable_exports.BadRequestError(
12754
+ _response.error.body,
12755
+ _response.rawResponse
12756
+ );
12757
+ case 401:
12758
+ throw new unstable_exports.UnauthorizedError(
12759
+ _response.error.body,
12760
+ _response.rawResponse
12761
+ );
12762
+ case 403:
12763
+ throw new unstable_exports.AccessDeniedError(
12764
+ _response.error.body,
12765
+ _response.rawResponse
12766
+ );
12767
+ case 404:
12768
+ throw new unstable_exports.NotFoundError(
12769
+ _response.error.body,
12770
+ _response.rawResponse
12771
+ );
12772
+ case 409:
12773
+ throw new unstable_exports.ConflictError(
12774
+ _response.error.body,
12775
+ _response.rawResponse
12776
+ );
12777
+ case 405:
12778
+ throw new unstable_exports.MethodNotAllowedError(
12779
+ _response.error.body,
12780
+ _response.rawResponse
12781
+ );
12782
+ case 422:
12783
+ throw new unstable_exports.UnprocessableContentError(
12784
+ _response.error.body,
12785
+ _response.rawResponse
12786
+ );
12787
+ case 429:
12788
+ throw new unstable_exports.TooManyRequestsError(
12789
+ _response.error.body,
12790
+ _response.rawResponse
12791
+ );
12792
+ case 500:
12793
+ throw new unstable_exports.InternalServerError(
12794
+ _response.error.body,
12795
+ _response.rawResponse
12796
+ );
12797
+ case 400:
12798
+ throw new Error2(
12799
+ _response.error.body,
12800
+ _response.rawResponse
12801
+ );
12802
+ case 401:
12803
+ throw new UnauthorizedError(
12804
+ _response.error.body,
12805
+ _response.rawResponse
12806
+ );
12807
+ case 403:
12808
+ throw new AccessDeniedError(
12809
+ _response.error.body,
12810
+ _response.rawResponse
12811
+ );
12812
+ case 405:
12813
+ throw new MethodNotAllowedError(
12814
+ _response.error.body,
12815
+ _response.rawResponse
12816
+ );
12817
+ case 404:
12818
+ throw new NotFoundError(
12819
+ _response.error.body,
12820
+ _response.rawResponse
12821
+ );
12822
+ default:
12823
+ throw new LangfuseAPIError({
12824
+ statusCode: _response.error.statusCode,
12825
+ body: _response.error.body,
12826
+ rawResponse: _response.rawResponse
12827
+ });
12828
+ }
12829
+ }
12830
+ switch (_response.error.reason) {
12831
+ case "non-json":
12832
+ throw new LangfuseAPIError({
12833
+ statusCode: _response.error.statusCode,
12834
+ body: _response.error.rawBody,
12835
+ rawResponse: _response.rawResponse
12836
+ });
12837
+ case "timeout":
12838
+ throw new LangfuseAPITimeoutError(
12839
+ "Timeout exceeded when calling POST /api/public/unstable/evaluation-rules."
12840
+ );
12841
+ case "unknown":
12842
+ throw new LangfuseAPIError({
12843
+ message: _response.error.errorMessage,
12844
+ rawResponse: _response.rawResponse
12845
+ });
12846
+ }
12847
+ }
12848
+ /**
12849
+ * List evaluation rules in the authenticated project.
12850
+ *
12851
+ * Each item describes one live evaluation rule and its effective runtime status.
12852
+ *
12853
+ * @param {LangfuseAPI.unstable.ListEvaluationRulesRequest} request
12854
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
12855
+ *
12856
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
12857
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
12858
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
12859
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
12860
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
12861
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
12862
+ * @throws {@link LangfuseAPI.Error}
12863
+ * @throws {@link LangfuseAPI.UnauthorizedError}
12864
+ * @throws {@link LangfuseAPI.AccessDeniedError}
12865
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
12866
+ * @throws {@link LangfuseAPI.NotFoundError}
12867
+ *
12868
+ * @example
12869
+ * await client.unstable.evaluationRules.list()
12870
+ */
12871
+ list(request = {}, requestOptions) {
12872
+ return HttpResponsePromise.fromPromise(
12873
+ this.__list(request, requestOptions)
12874
+ );
12875
+ }
12876
+ async __list(request = {}, requestOptions) {
12877
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
12878
+ const { page, limit } = request;
12879
+ const _queryParams = {};
12880
+ if (page != null) {
12881
+ _queryParams["page"] = page.toString();
12882
+ }
12883
+ if (limit != null) {
12884
+ _queryParams["limit"] = limit.toString();
12885
+ }
12886
+ let _headers = mergeHeaders(
12887
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
12888
+ mergeOnlyDefinedHeaders({
12889
+ Authorization: await this._getAuthorizationHeader(),
12890
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
12891
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
12892
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
12893
+ }),
12894
+ requestOptions == null ? void 0 : requestOptions.headers
12895
+ );
12896
+ const _response = await fetcher({
12897
+ url: url_exports.join(
12898
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
12899
+ "/api/public/unstable/evaluation-rules"
12900
+ ),
12901
+ method: "GET",
12902
+ headers: _headers,
12903
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
12904
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
12905
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
12906
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
12907
+ });
12908
+ if (_response.ok) {
12909
+ return {
12910
+ data: _response.body,
12911
+ rawResponse: _response.rawResponse
12912
+ };
12913
+ }
12914
+ if (_response.error.reason === "status-code") {
12915
+ switch (_response.error.statusCode) {
12916
+ case 400:
12917
+ throw new unstable_exports.BadRequestError(
12918
+ _response.error.body,
12919
+ _response.rawResponse
12920
+ );
12921
+ case 401:
12922
+ throw new unstable_exports.UnauthorizedError(
12923
+ _response.error.body,
12924
+ _response.rawResponse
12925
+ );
12926
+ case 403:
12927
+ throw new unstable_exports.AccessDeniedError(
12928
+ _response.error.body,
12929
+ _response.rawResponse
12930
+ );
12931
+ case 405:
12932
+ throw new unstable_exports.MethodNotAllowedError(
12933
+ _response.error.body,
12934
+ _response.rawResponse
12935
+ );
12936
+ case 429:
12937
+ throw new unstable_exports.TooManyRequestsError(
12938
+ _response.error.body,
12939
+ _response.rawResponse
12940
+ );
12941
+ case 500:
12942
+ throw new unstable_exports.InternalServerError(
12943
+ _response.error.body,
12944
+ _response.rawResponse
12945
+ );
12946
+ case 400:
12947
+ throw new Error2(
12948
+ _response.error.body,
12949
+ _response.rawResponse
12950
+ );
12951
+ case 401:
12952
+ throw new UnauthorizedError(
12953
+ _response.error.body,
12954
+ _response.rawResponse
12955
+ );
12956
+ case 403:
12957
+ throw new AccessDeniedError(
12958
+ _response.error.body,
12959
+ _response.rawResponse
12960
+ );
12961
+ case 405:
12962
+ throw new MethodNotAllowedError(
12963
+ _response.error.body,
12964
+ _response.rawResponse
12965
+ );
12966
+ case 404:
12967
+ throw new NotFoundError(
12968
+ _response.error.body,
12969
+ _response.rawResponse
12970
+ );
12971
+ default:
12972
+ throw new LangfuseAPIError({
12973
+ statusCode: _response.error.statusCode,
12974
+ body: _response.error.body,
12975
+ rawResponse: _response.rawResponse
12976
+ });
12977
+ }
12978
+ }
12979
+ switch (_response.error.reason) {
12980
+ case "non-json":
12981
+ throw new LangfuseAPIError({
12982
+ statusCode: _response.error.statusCode,
12983
+ body: _response.error.rawBody,
12984
+ rawResponse: _response.rawResponse
12985
+ });
12986
+ case "timeout":
12987
+ throw new LangfuseAPITimeoutError(
12988
+ "Timeout exceeded when calling GET /api/public/unstable/evaluation-rules."
12989
+ );
12990
+ case "unknown":
12991
+ throw new LangfuseAPIError({
12992
+ message: _response.error.errorMessage,
12993
+ rawResponse: _response.rawResponse
12994
+ });
12995
+ }
12996
+ }
12997
+ /**
12998
+ * Get one evaluation rule by its identifier.
12999
+ *
13000
+ * Use this endpoint to inspect the current evaluator, target, mapping, filters, and effective runtime status.
13001
+ *
13002
+ * @param {string} evaluationRuleId - Evaluation rule identifier returned by the evaluation rule endpoints.
13003
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
13004
+ *
13005
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13006
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13007
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13008
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
13009
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13010
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13011
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13012
+ * @throws {@link LangfuseAPI.Error}
13013
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13014
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13015
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13016
+ * @throws {@link LangfuseAPI.NotFoundError}
13017
+ *
13018
+ * @example
13019
+ * await client.unstable.evaluationRules.get("evaluationRuleId")
13020
+ */
13021
+ get(evaluationRuleId, requestOptions) {
13022
+ return HttpResponsePromise.fromPromise(
13023
+ this.__get(evaluationRuleId, requestOptions)
13024
+ );
13025
+ }
13026
+ async __get(evaluationRuleId, requestOptions) {
13027
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13028
+ let _headers = mergeHeaders(
13029
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13030
+ mergeOnlyDefinedHeaders({
13031
+ Authorization: await this._getAuthorizationHeader(),
13032
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13033
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13034
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13035
+ }),
13036
+ requestOptions == null ? void 0 : requestOptions.headers
13037
+ );
13038
+ const _response = await fetcher({
13039
+ url: url_exports.join(
13040
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13041
+ `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
13042
+ ),
13043
+ method: "GET",
13044
+ headers: _headers,
13045
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13046
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13047
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13048
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13049
+ });
13050
+ if (_response.ok) {
13051
+ return {
13052
+ data: _response.body,
13053
+ rawResponse: _response.rawResponse
13054
+ };
13055
+ }
13056
+ if (_response.error.reason === "status-code") {
13057
+ switch (_response.error.statusCode) {
13058
+ case 400:
13059
+ throw new unstable_exports.BadRequestError(
13060
+ _response.error.body,
13061
+ _response.rawResponse
13062
+ );
13063
+ case 401:
13064
+ throw new unstable_exports.UnauthorizedError(
13065
+ _response.error.body,
13066
+ _response.rawResponse
13067
+ );
13068
+ case 403:
13069
+ throw new unstable_exports.AccessDeniedError(
13070
+ _response.error.body,
13071
+ _response.rawResponse
13072
+ );
13073
+ case 404:
13074
+ throw new unstable_exports.NotFoundError(
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/{evaluationRuleId}."
13136
+ );
13137
+ case "unknown":
13138
+ throw new LangfuseAPIError({
13139
+ message: _response.error.errorMessage,
13140
+ rawResponse: _response.rawResponse
13141
+ });
13142
+ }
13143
+ }
13144
+ /**
13145
+ * Update an evaluation rule.
13146
+ *
13147
+ * Typical uses:
13148
+ * - enable or disable live execution
13149
+ * - switch to another evaluator
13150
+ * - adjust sampling
13151
+ * - change filters
13152
+ * - update variable mappings
13153
+ *
13154
+ * Important behavior:
13155
+ * - provide only the fields you want to change
13156
+ * - if you provide `evaluator`, Langfuse resolves that evaluator family to its latest version before saving
13157
+ * - changing `target`, `filter`, or `mapping` must still produce a valid target-specific configuration
13158
+ * - if you change `target`, also send a compatible `filter` and `mapping` in the same request unless the existing ones are still valid for the new target
13159
+ * - if the resulting config is enabled, Langfuse re-validates that the selected evaluator can run
13160
+ * - 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`
13161
+ *
13162
+ * Recovery guidance:
13163
+ * - if the update fails with `missing_variable_mapping` or `invalid_variable_mapping` after changing `evaluator` or `target`, resend the request with a complete new `mapping`
13164
+ * - if the update fails with `invalid_filter_value` after changing `target`, resend the request with a target-compatible `filter`
13165
+ *
13166
+ * @param {string} evaluationRuleId - Evaluation rule identifier.
13167
+ * @param {LangfuseAPI.unstable.UpdateEvaluationRuleRequest} request
13168
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
13169
+ *
13170
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13171
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13172
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13173
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
13174
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13175
+ * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
13176
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13177
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13178
+ * @throws {@link LangfuseAPI.Error}
13179
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13180
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13181
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13182
+ * @throws {@link LangfuseAPI.NotFoundError}
13183
+ *
13184
+ * @example
13185
+ * await client.unstable.evaluationRules.update("evaluationRuleId", {
13186
+ * name: undefined,
13187
+ * evaluator: undefined,
13188
+ * target: undefined,
13189
+ * enabled: undefined,
13190
+ * sampling: undefined,
13191
+ * filter: undefined,
13192
+ * mapping: undefined
13193
+ * })
13194
+ */
13195
+ update(evaluationRuleId, request, requestOptions) {
13196
+ return HttpResponsePromise.fromPromise(
13197
+ this.__update(evaluationRuleId, request, requestOptions)
13198
+ );
13199
+ }
13200
+ async __update(evaluationRuleId, request, requestOptions) {
13201
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13202
+ let _headers = mergeHeaders(
13203
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13204
+ mergeOnlyDefinedHeaders({
13205
+ Authorization: await this._getAuthorizationHeader(),
13206
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13207
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13208
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13209
+ }),
13210
+ requestOptions == null ? void 0 : requestOptions.headers
13211
+ );
13212
+ const _response = await fetcher({
13213
+ url: url_exports.join(
13214
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13215
+ `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
13216
+ ),
13217
+ method: "PATCH",
13218
+ headers: _headers,
13219
+ contentType: "application/json",
13220
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13221
+ requestType: "json",
13222
+ body: request,
13223
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13224
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13225
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13226
+ });
13227
+ if (_response.ok) {
13228
+ return {
13229
+ data: _response.body,
13230
+ rawResponse: _response.rawResponse
13231
+ };
13232
+ }
13233
+ if (_response.error.reason === "status-code") {
13234
+ switch (_response.error.statusCode) {
13235
+ case 400:
13236
+ throw new unstable_exports.BadRequestError(
13237
+ _response.error.body,
13238
+ _response.rawResponse
13239
+ );
13240
+ case 401:
13241
+ throw new unstable_exports.UnauthorizedError(
13242
+ _response.error.body,
13243
+ _response.rawResponse
13244
+ );
13245
+ case 403:
13246
+ throw new unstable_exports.AccessDeniedError(
13247
+ _response.error.body,
13248
+ _response.rawResponse
13249
+ );
13250
+ case 404:
13251
+ throw new unstable_exports.NotFoundError(
13252
+ _response.error.body,
13253
+ _response.rawResponse
13254
+ );
13255
+ case 405:
13256
+ throw new unstable_exports.MethodNotAllowedError(
13257
+ _response.error.body,
13258
+ _response.rawResponse
13259
+ );
13260
+ case 422:
13261
+ throw new unstable_exports.UnprocessableContentError(
13262
+ _response.error.body,
13263
+ _response.rawResponse
13264
+ );
13265
+ case 429:
13266
+ throw new unstable_exports.TooManyRequestsError(
13267
+ _response.error.body,
13268
+ _response.rawResponse
13269
+ );
13270
+ case 500:
13271
+ throw new unstable_exports.InternalServerError(
13272
+ _response.error.body,
13273
+ _response.rawResponse
13274
+ );
13275
+ case 400:
13276
+ throw new Error2(
13277
+ _response.error.body,
13278
+ _response.rawResponse
13279
+ );
13280
+ case 401:
13281
+ throw new UnauthorizedError(
13282
+ _response.error.body,
13283
+ _response.rawResponse
13284
+ );
13285
+ case 403:
13286
+ throw new AccessDeniedError(
13287
+ _response.error.body,
13288
+ _response.rawResponse
13289
+ );
13290
+ case 405:
13291
+ throw new MethodNotAllowedError(
13292
+ _response.error.body,
13293
+ _response.rawResponse
13294
+ );
13295
+ case 404:
13296
+ throw new NotFoundError(
13297
+ _response.error.body,
13298
+ _response.rawResponse
13299
+ );
13300
+ default:
13301
+ throw new LangfuseAPIError({
13302
+ statusCode: _response.error.statusCode,
13303
+ body: _response.error.body,
13304
+ rawResponse: _response.rawResponse
13305
+ });
13306
+ }
13307
+ }
13308
+ switch (_response.error.reason) {
13309
+ case "non-json":
13310
+ throw new LangfuseAPIError({
13311
+ statusCode: _response.error.statusCode,
13312
+ body: _response.error.rawBody,
13313
+ rawResponse: _response.rawResponse
13314
+ });
13315
+ case "timeout":
13316
+ throw new LangfuseAPITimeoutError(
13317
+ "Timeout exceeded when calling PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}."
13318
+ );
13319
+ case "unknown":
13320
+ throw new LangfuseAPIError({
13321
+ message: _response.error.errorMessage,
13322
+ rawResponse: _response.rawResponse
13323
+ });
13324
+ }
13325
+ }
13326
+ /**
13327
+ * Delete an evaluation rule.
13328
+ *
13329
+ * This removes the live-ingestion rule only. It does not delete the referenced evaluator.
13330
+ *
13331
+ * @param {string} evaluationRuleId - Evaluation rule identifier.
13332
+ * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
13333
+ *
13334
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13335
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13336
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13337
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
13338
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13339
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13340
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13341
+ * @throws {@link LangfuseAPI.Error}
13342
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13343
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13344
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13345
+ * @throws {@link LangfuseAPI.NotFoundError}
13346
+ *
13347
+ * @example
13348
+ * await client.unstable.evaluationRules.delete("evaluationRuleId")
13349
+ */
13350
+ delete(evaluationRuleId, requestOptions) {
13351
+ return HttpResponsePromise.fromPromise(
13352
+ this.__delete(evaluationRuleId, requestOptions)
13353
+ );
13354
+ }
13355
+ async __delete(evaluationRuleId, requestOptions) {
13356
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13357
+ let _headers = mergeHeaders(
13358
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13359
+ mergeOnlyDefinedHeaders({
13360
+ Authorization: await this._getAuthorizationHeader(),
13361
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13362
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13363
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13364
+ }),
13365
+ requestOptions == null ? void 0 : requestOptions.headers
13366
+ );
13367
+ const _response = await fetcher({
13368
+ url: url_exports.join(
13369
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13370
+ `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
13371
+ ),
13372
+ method: "DELETE",
13373
+ headers: _headers,
13374
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13375
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13376
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13377
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13378
+ });
13379
+ if (_response.ok) {
13380
+ return {
13381
+ data: _response.body,
13382
+ rawResponse: _response.rawResponse
13383
+ };
13384
+ }
13385
+ if (_response.error.reason === "status-code") {
13386
+ switch (_response.error.statusCode) {
13387
+ case 400:
13388
+ throw new unstable_exports.BadRequestError(
13389
+ _response.error.body,
13390
+ _response.rawResponse
13391
+ );
13392
+ case 401:
13393
+ throw new unstable_exports.UnauthorizedError(
13394
+ _response.error.body,
13395
+ _response.rawResponse
13396
+ );
13397
+ case 403:
13398
+ throw new unstable_exports.AccessDeniedError(
13399
+ _response.error.body,
13400
+ _response.rawResponse
13401
+ );
13402
+ case 404:
13403
+ throw new unstable_exports.NotFoundError(
13404
+ _response.error.body,
13405
+ _response.rawResponse
13406
+ );
13407
+ case 405:
13408
+ throw new unstable_exports.MethodNotAllowedError(
13409
+ _response.error.body,
13410
+ _response.rawResponse
13411
+ );
13412
+ case 429:
13413
+ throw new unstable_exports.TooManyRequestsError(
13414
+ _response.error.body,
13415
+ _response.rawResponse
13416
+ );
13417
+ case 500:
13418
+ throw new unstable_exports.InternalServerError(
13419
+ _response.error.body,
13420
+ _response.rawResponse
13421
+ );
13422
+ case 400:
13423
+ throw new Error2(
13424
+ _response.error.body,
13425
+ _response.rawResponse
13426
+ );
13427
+ case 401:
13428
+ throw new UnauthorizedError(
13429
+ _response.error.body,
13430
+ _response.rawResponse
13431
+ );
13432
+ case 403:
13433
+ throw new AccessDeniedError(
13434
+ _response.error.body,
13435
+ _response.rawResponse
13436
+ );
13437
+ case 405:
13438
+ throw new MethodNotAllowedError(
13439
+ _response.error.body,
13440
+ _response.rawResponse
13441
+ );
13442
+ case 404:
13443
+ throw new NotFoundError(
13444
+ _response.error.body,
13445
+ _response.rawResponse
13446
+ );
13447
+ default:
13448
+ throw new LangfuseAPIError({
13449
+ statusCode: _response.error.statusCode,
13450
+ body: _response.error.body,
13451
+ rawResponse: _response.rawResponse
13452
+ });
13453
+ }
13454
+ }
13455
+ switch (_response.error.reason) {
13456
+ case "non-json":
13457
+ throw new LangfuseAPIError({
13458
+ statusCode: _response.error.statusCode,
13459
+ body: _response.error.rawBody,
13460
+ rawResponse: _response.rawResponse
13461
+ });
13462
+ case "timeout":
13463
+ throw new LangfuseAPITimeoutError(
13464
+ "Timeout exceeded when calling DELETE /api/public/unstable/evaluation-rules/{evaluationRuleId}."
13465
+ );
13466
+ case "unknown":
13467
+ throw new LangfuseAPIError({
13468
+ message: _response.error.errorMessage,
13469
+ rawResponse: _response.rawResponse
13470
+ });
13471
+ }
13472
+ }
13473
+ async _getAuthorizationHeader() {
13474
+ const username = await Supplier.get(this._options.username);
13475
+ const password = await Supplier.get(this._options.password);
13476
+ if (username != null && password != null) {
13477
+ return BasicAuth.toAuthorizationHeader({
13478
+ username,
13479
+ password
13480
+ });
13481
+ }
13482
+ return void 0;
13483
+ }
13484
+ };
13485
+
13486
+ // src/api/api/resources/unstable/resources/evaluators/client/Client.ts
13487
+ var Evaluators = class {
13488
+ constructor(_options) {
13489
+ this._options = _options;
13490
+ }
13491
+ /**
13492
+ * Create an evaluator in the authenticated project.
13493
+ *
13494
+ * Use evaluators to define **how** Langfuse should score data: the prompt, the expected structured output, and the optional model configuration.
13495
+ *
13496
+ * Naming behavior:
13497
+ * - If this is a new evaluator name in your project, Langfuse creates version `1`.
13498
+ * - If the name already exists in your project, Langfuse creates the next version and returns it.
13499
+ * - When a new project version is created, existing evaluation rules in that project automatically move to the newest version for that evaluator name.
13500
+ *
13501
+ * Recommended workflow:
13502
+ * 1. Create the evaluator.
13503
+ * 2. Read the returned `variables` array.
13504
+ * 3. Read the returned `outputDefinition.dataType` so the client knows whether future scores will be numeric, boolean, or categorical.
13505
+ * 4. Create one or more evaluation rules that reference the returned evaluator family using `name` and `scope`.
13506
+ *
13507
+ * Recovery guidance:
13508
+ * - `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.
13509
+ * - `400` with `code=invalid_body`: the request shape is malformed. Use the structured `details.issues` array to fix the specific fields and retry.
13510
+ * - `400` with `code=invalid_body` on `outputDefinition`: send `dataType`, `reasoning.description`, and `score.description`. Do not send `version`; it is not part of the public request shape.
13511
+ *
13512
+ * Unstable API note:
13513
+ * - This surface may evolve while the underlying evaluation data model is being redesigned.
13514
+ *
13515
+ * @param {LangfuseAPI.unstable.CreateEvaluatorRequest} request
13516
+ * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
13517
+ *
13518
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13519
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13520
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13521
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13522
+ * @throws {@link LangfuseAPI.unstable.ConflictError}
13523
+ * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
13524
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13525
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13526
+ * @throws {@link LangfuseAPI.Error}
13527
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13528
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13529
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13530
+ * @throws {@link LangfuseAPI.NotFoundError}
13531
+ *
13532
+ * @example
13533
+ * await client.unstable.evaluators.create({
13534
+ * name: "answer-correctness",
13535
+ * prompt: "You are grading an answer.\n\nInput:\n{{input}}\n\nOutput:\n{{output}}\n\nReturn a score between 0 and 1.\n",
13536
+ * outputDefinition: {
13537
+ * dataType: "NUMERIC",
13538
+ * dataType: "NUMERIC",
13539
+ * reasoning: {
13540
+ * description: "Explain why the score was assigned."
13541
+ * },
13542
+ * score: {
13543
+ * description: "Correctness score between 0 and 1."
13544
+ * }
13545
+ * },
13546
+ * modelConfig: {
13547
+ * provider: "openai",
13548
+ * model: "gpt-4.1-mini"
13549
+ * }
13550
+ * })
13551
+ */
13552
+ create(request, requestOptions) {
13553
+ return HttpResponsePromise.fromPromise(
13554
+ this.__create(request, requestOptions)
13555
+ );
13556
+ }
13557
+ async __create(request, requestOptions) {
13558
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13559
+ let _headers = mergeHeaders(
13560
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13561
+ mergeOnlyDefinedHeaders({
13562
+ Authorization: await this._getAuthorizationHeader(),
13563
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13564
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13565
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13566
+ }),
13567
+ requestOptions == null ? void 0 : requestOptions.headers
13568
+ );
13569
+ const _response = await fetcher({
13570
+ url: url_exports.join(
13571
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13572
+ "/api/public/unstable/evaluators"
13573
+ ),
13574
+ method: "POST",
13575
+ headers: _headers,
13576
+ contentType: "application/json",
13577
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13578
+ requestType: "json",
13579
+ body: request,
13580
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13581
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13582
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13583
+ });
13584
+ if (_response.ok) {
13585
+ return {
13586
+ data: _response.body,
13587
+ rawResponse: _response.rawResponse
13588
+ };
13589
+ }
13590
+ if (_response.error.reason === "status-code") {
13591
+ switch (_response.error.statusCode) {
13592
+ case 400:
13593
+ throw new unstable_exports.BadRequestError(
13594
+ _response.error.body,
13595
+ _response.rawResponse
13596
+ );
13597
+ case 401:
13598
+ throw new unstable_exports.UnauthorizedError(
13599
+ _response.error.body,
13600
+ _response.rawResponse
13601
+ );
13602
+ case 403:
13603
+ throw new unstable_exports.AccessDeniedError(
13604
+ _response.error.body,
13605
+ _response.rawResponse
13606
+ );
13607
+ case 405:
13608
+ throw new unstable_exports.MethodNotAllowedError(
13609
+ _response.error.body,
13610
+ _response.rawResponse
13611
+ );
13612
+ case 409:
13613
+ throw new unstable_exports.ConflictError(
13614
+ _response.error.body,
13615
+ _response.rawResponse
13616
+ );
13617
+ case 422:
13618
+ throw new unstable_exports.UnprocessableContentError(
13619
+ _response.error.body,
13620
+ _response.rawResponse
13621
+ );
13622
+ case 429:
13623
+ throw new unstable_exports.TooManyRequestsError(
13624
+ _response.error.body,
13625
+ _response.rawResponse
13626
+ );
13627
+ case 500:
13628
+ throw new unstable_exports.InternalServerError(
13629
+ _response.error.body,
13630
+ _response.rawResponse
13631
+ );
13632
+ case 400:
13633
+ throw new Error2(
13634
+ _response.error.body,
13635
+ _response.rawResponse
13636
+ );
13637
+ case 401:
13638
+ throw new UnauthorizedError(
13639
+ _response.error.body,
13640
+ _response.rawResponse
13641
+ );
13642
+ case 403:
13643
+ throw new AccessDeniedError(
13644
+ _response.error.body,
13645
+ _response.rawResponse
13646
+ );
13647
+ case 405:
13648
+ throw new MethodNotAllowedError(
13649
+ _response.error.body,
13650
+ _response.rawResponse
13651
+ );
13652
+ case 404:
13653
+ throw new NotFoundError(
13654
+ _response.error.body,
13655
+ _response.rawResponse
13656
+ );
13657
+ default:
13658
+ throw new LangfuseAPIError({
13659
+ statusCode: _response.error.statusCode,
13660
+ body: _response.error.body,
13661
+ rawResponse: _response.rawResponse
13662
+ });
13663
+ }
13664
+ }
13665
+ switch (_response.error.reason) {
13666
+ case "non-json":
13667
+ throw new LangfuseAPIError({
13668
+ statusCode: _response.error.statusCode,
13669
+ body: _response.error.rawBody,
13670
+ rawResponse: _response.rawResponse
13671
+ });
13672
+ case "timeout":
13673
+ throw new LangfuseAPITimeoutError(
13674
+ "Timeout exceeded when calling POST /api/public/unstable/evaluators."
13675
+ );
13676
+ case "unknown":
13677
+ throw new LangfuseAPIError({
13678
+ message: _response.error.errorMessage,
13679
+ rawResponse: _response.rawResponse
13680
+ });
13681
+ }
13682
+ }
13683
+ /**
13684
+ * List the evaluators available to the authenticated project.
13685
+ *
13686
+ * Important behavior:
13687
+ * - This endpoint returns the latest version of each available evaluator.
13688
+ * - Results can include evaluators from your project and Langfuse-managed evaluators.
13689
+ * - If the same evaluator name exists in both places, both are returned as separate items with different `scope` values.
13690
+ *
13691
+ * @param {LangfuseAPI.unstable.ListEvaluatorsRequest} request
13692
+ * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
13693
+ *
13694
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13695
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13696
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13697
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13698
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13699
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13700
+ * @throws {@link LangfuseAPI.Error}
13701
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13702
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13703
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13704
+ * @throws {@link LangfuseAPI.NotFoundError}
13705
+ *
13706
+ * @example
13707
+ * await client.unstable.evaluators.list()
13708
+ */
13709
+ list(request = {}, requestOptions) {
13710
+ return HttpResponsePromise.fromPromise(
13711
+ this.__list(request, requestOptions)
13712
+ );
13713
+ }
13714
+ async __list(request = {}, requestOptions) {
13715
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13716
+ const { page, limit } = request;
13717
+ const _queryParams = {};
13718
+ if (page != null) {
13719
+ _queryParams["page"] = page.toString();
13720
+ }
13721
+ if (limit != null) {
13722
+ _queryParams["limit"] = limit.toString();
13723
+ }
13724
+ let _headers = mergeHeaders(
13725
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13726
+ mergeOnlyDefinedHeaders({
13727
+ Authorization: await this._getAuthorizationHeader(),
13728
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13729
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13730
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13731
+ }),
13732
+ requestOptions == null ? void 0 : requestOptions.headers
13733
+ );
13734
+ const _response = await fetcher({
13735
+ url: url_exports.join(
13736
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13737
+ "/api/public/unstable/evaluators"
13738
+ ),
13739
+ method: "GET",
13740
+ headers: _headers,
13741
+ queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
13742
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13743
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13744
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13745
+ });
13746
+ if (_response.ok) {
13747
+ return {
13748
+ data: _response.body,
13749
+ rawResponse: _response.rawResponse
13750
+ };
13751
+ }
13752
+ if (_response.error.reason === "status-code") {
13753
+ switch (_response.error.statusCode) {
13754
+ case 400:
13755
+ throw new unstable_exports.BadRequestError(
13756
+ _response.error.body,
13757
+ _response.rawResponse
13758
+ );
13759
+ case 401:
13760
+ throw new unstable_exports.UnauthorizedError(
13761
+ _response.error.body,
13762
+ _response.rawResponse
13763
+ );
13764
+ case 403:
13765
+ throw new unstable_exports.AccessDeniedError(
13766
+ _response.error.body,
13767
+ _response.rawResponse
13768
+ );
13769
+ case 405:
13770
+ throw new unstable_exports.MethodNotAllowedError(
13771
+ _response.error.body,
13772
+ _response.rawResponse
13773
+ );
13774
+ case 429:
13775
+ throw new unstable_exports.TooManyRequestsError(
13776
+ _response.error.body,
13777
+ _response.rawResponse
13778
+ );
13779
+ case 500:
13780
+ throw new unstable_exports.InternalServerError(
13781
+ _response.error.body,
13782
+ _response.rawResponse
13783
+ );
13784
+ case 400:
13785
+ throw new Error2(
13786
+ _response.error.body,
13787
+ _response.rawResponse
13788
+ );
13789
+ case 401:
13790
+ throw new UnauthorizedError(
13791
+ _response.error.body,
13792
+ _response.rawResponse
13793
+ );
13794
+ case 403:
13795
+ throw new AccessDeniedError(
13796
+ _response.error.body,
13797
+ _response.rawResponse
13798
+ );
13799
+ case 405:
13800
+ throw new MethodNotAllowedError(
13801
+ _response.error.body,
13802
+ _response.rawResponse
13803
+ );
13804
+ case 404:
13805
+ throw new NotFoundError(
13806
+ _response.error.body,
13807
+ _response.rawResponse
13808
+ );
13809
+ default:
13810
+ throw new LangfuseAPIError({
13811
+ statusCode: _response.error.statusCode,
13812
+ body: _response.error.body,
13813
+ rawResponse: _response.rawResponse
13814
+ });
13815
+ }
13816
+ }
13817
+ switch (_response.error.reason) {
13818
+ case "non-json":
13819
+ throw new LangfuseAPIError({
13820
+ statusCode: _response.error.statusCode,
13821
+ body: _response.error.rawBody,
13822
+ rawResponse: _response.rawResponse
13823
+ });
13824
+ case "timeout":
13825
+ throw new LangfuseAPITimeoutError(
13826
+ "Timeout exceeded when calling GET /api/public/unstable/evaluators."
13827
+ );
13828
+ case "unknown":
13829
+ throw new LangfuseAPIError({
13830
+ message: _response.error.errorMessage,
13831
+ rawResponse: _response.rawResponse
13832
+ });
13833
+ }
13834
+ }
13835
+ /**
13836
+ * Get one evaluator by `id`.
13837
+ *
13838
+ * 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.
13839
+ *
13840
+ * @param {string} evaluatorId - Evaluator identifier returned by the evaluator endpoints.
13841
+ * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
13842
+ *
13843
+ * @throws {@link LangfuseAPI.unstable.BadRequestError}
13844
+ * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
13845
+ * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
13846
+ * @throws {@link LangfuseAPI.unstable.NotFoundError}
13847
+ * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
13848
+ * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
13849
+ * @throws {@link LangfuseAPI.unstable.InternalServerError}
13850
+ * @throws {@link LangfuseAPI.Error}
13851
+ * @throws {@link LangfuseAPI.UnauthorizedError}
13852
+ * @throws {@link LangfuseAPI.AccessDeniedError}
13853
+ * @throws {@link LangfuseAPI.MethodNotAllowedError}
13854
+ * @throws {@link LangfuseAPI.NotFoundError}
13855
+ *
13856
+ * @example
13857
+ * await client.unstable.evaluators.get("evaluatorId")
13858
+ */
13859
+ get(evaluatorId, requestOptions) {
13860
+ return HttpResponsePromise.fromPromise(
13861
+ this.__get(evaluatorId, requestOptions)
13862
+ );
13863
+ }
13864
+ async __get(evaluatorId, requestOptions) {
13865
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
13866
+ let _headers = mergeHeaders(
13867
+ (_a2 = this._options) == null ? void 0 : _a2.headers,
13868
+ mergeOnlyDefinedHeaders({
13869
+ Authorization: await this._getAuthorizationHeader(),
13870
+ "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
13871
+ "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
13872
+ "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
13873
+ }),
13874
+ requestOptions == null ? void 0 : requestOptions.headers
13875
+ );
13876
+ const _response = await fetcher({
13877
+ url: url_exports.join(
13878
+ (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
13879
+ `/api/public/unstable/evaluators/${encodeURIComponent(evaluatorId)}`
13880
+ ),
13881
+ method: "GET",
13882
+ headers: _headers,
13883
+ queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
13884
+ timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
13885
+ maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
13886
+ abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
13887
+ });
13888
+ if (_response.ok) {
13889
+ return {
13890
+ data: _response.body,
13891
+ rawResponse: _response.rawResponse
13892
+ };
13893
+ }
13894
+ if (_response.error.reason === "status-code") {
13895
+ switch (_response.error.statusCode) {
13896
+ case 400:
13897
+ throw new unstable_exports.BadRequestError(
13898
+ _response.error.body,
13899
+ _response.rawResponse
13900
+ );
13901
+ case 401:
13902
+ throw new unstable_exports.UnauthorizedError(
13903
+ _response.error.body,
13904
+ _response.rawResponse
13905
+ );
13906
+ case 403:
13907
+ throw new unstable_exports.AccessDeniedError(
13908
+ _response.error.body,
13909
+ _response.rawResponse
13910
+ );
13911
+ case 404:
13912
+ throw new unstable_exports.NotFoundError(
13913
+ _response.error.body,
13914
+ _response.rawResponse
13915
+ );
13916
+ case 405:
13917
+ throw new unstable_exports.MethodNotAllowedError(
13918
+ _response.error.body,
13919
+ _response.rawResponse
13920
+ );
13921
+ case 429:
13922
+ throw new unstable_exports.TooManyRequestsError(
13923
+ _response.error.body,
13924
+ _response.rawResponse
13925
+ );
13926
+ case 500:
13927
+ throw new unstable_exports.InternalServerError(
13928
+ _response.error.body,
13929
+ _response.rawResponse
13930
+ );
13931
+ case 400:
13932
+ throw new Error2(
13933
+ _response.error.body,
13934
+ _response.rawResponse
13935
+ );
13936
+ case 401:
13937
+ throw new UnauthorizedError(
13938
+ _response.error.body,
13939
+ _response.rawResponse
13940
+ );
13941
+ case 403:
13942
+ throw new AccessDeniedError(
13943
+ _response.error.body,
13944
+ _response.rawResponse
13945
+ );
13946
+ case 405:
13947
+ throw new MethodNotAllowedError(
13948
+ _response.error.body,
13949
+ _response.rawResponse
13950
+ );
13951
+ case 404:
13952
+ throw new NotFoundError(
13953
+ _response.error.body,
13954
+ _response.rawResponse
13955
+ );
13956
+ default:
13957
+ throw new LangfuseAPIError({
13958
+ statusCode: _response.error.statusCode,
13959
+ body: _response.error.body,
13960
+ rawResponse: _response.rawResponse
13961
+ });
13962
+ }
13963
+ }
13964
+ switch (_response.error.reason) {
13965
+ case "non-json":
13966
+ throw new LangfuseAPIError({
13967
+ statusCode: _response.error.statusCode,
13968
+ body: _response.error.rawBody,
13969
+ rawResponse: _response.rawResponse
13970
+ });
13971
+ case "timeout":
13972
+ throw new LangfuseAPITimeoutError(
13973
+ "Timeout exceeded when calling GET /api/public/unstable/evaluators/{evaluatorId}."
13974
+ );
13975
+ case "unknown":
13976
+ throw new LangfuseAPIError({
13977
+ message: _response.error.errorMessage,
13978
+ rawResponse: _response.rawResponse
13979
+ });
13980
+ }
13981
+ }
13982
+ async _getAuthorizationHeader() {
13983
+ const username = await Supplier.get(this._options.username);
13984
+ const password = await Supplier.get(this._options.password);
13985
+ if (username != null && password != null) {
13986
+ return BasicAuth.toAuthorizationHeader({
13987
+ username,
13988
+ password
13989
+ });
13990
+ }
13991
+ return void 0;
13992
+ }
13993
+ };
13994
+
13995
+ // src/api/api/resources/unstable/client/Client.ts
13996
+ var Unstable = class {
13997
+ constructor(_options) {
13998
+ this._options = _options;
13999
+ }
14000
+ get evaluationRules() {
14001
+ var _a2;
14002
+ return (_a2 = this._evaluationRules) != null ? _a2 : this._evaluationRules = new EvaluationRules(this._options);
14003
+ }
14004
+ get evaluators() {
14005
+ var _a2;
14006
+ return (_a2 = this._evaluators) != null ? _a2 : this._evaluators = new Evaluators(this._options);
14007
+ }
14008
+ };
14009
+
14010
+ // src/api/Client.ts
14011
+ var LangfuseAPIClient = class {
14012
+ constructor(_options) {
14013
+ this._options = {
14014
+ ..._options,
14015
+ headers: mergeHeaders(
14016
+ {
14017
+ "X-Langfuse-Sdk-Name": _options == null ? void 0 : _options.xLangfuseSdkName,
14018
+ "X-Langfuse-Sdk-Version": _options == null ? void 0 : _options.xLangfuseSdkVersion,
14019
+ "X-Langfuse-Public-Key": _options == null ? void 0 : _options.xLangfusePublicKey
14020
+ },
14021
+ _options == null ? void 0 : _options.headers
14022
+ )
14023
+ };
14024
+ }
14025
+ get annotationQueues() {
14026
+ var _a2;
14027
+ return (_a2 = this._annotationQueues) != null ? _a2 : this._annotationQueues = new AnnotationQueues(this._options);
14028
+ }
14029
+ get blobStorageIntegrations() {
14030
+ var _a2;
14031
+ return (_a2 = this._blobStorageIntegrations) != null ? _a2 : this._blobStorageIntegrations = new BlobStorageIntegrations(
14032
+ this._options
14033
+ );
14034
+ }
14035
+ get comments() {
14036
+ var _a2;
14037
+ return (_a2 = this._comments) != null ? _a2 : this._comments = new Comments(this._options);
12194
14038
  }
12195
14039
  get datasetItems() {
12196
14040
  var _a2;
@@ -12276,6 +14120,10 @@ var LangfuseAPIClient = class {
12276
14120
  var _a2;
12277
14121
  return (_a2 = this._trace) != null ? _a2 : this._trace = new Trace(this._options);
12278
14122
  }
14123
+ get unstable() {
14124
+ var _a2;
14125
+ return (_a2 = this._unstable) != null ? _a2 : this._unstable = new Unstable(this._options);
14126
+ }
12279
14127
  };
12280
14128
 
12281
14129
  // src/media.ts
@@ -12859,8 +14707,10 @@ function getSpanKeyFromBaggageKey(baggageKey) {
12859
14707
  AccessDeniedError,
12860
14708
  AnnotationQueueObjectType,
12861
14709
  AnnotationQueueStatus,
14710
+ BlobStorageExportFieldGroup,
12862
14711
  BlobStorageExportFrequency,
12863
14712
  BlobStorageExportMode,
14713
+ BlobStorageExportSource,
12864
14714
  BlobStorageIntegrationFileType,
12865
14715
  BlobStorageIntegrationType,
12866
14716
  BlobStorageSyncStatus,
@@ -12943,6 +14793,7 @@ function getSpanKeyFromBaggageKey(baggageKey) {
12943
14793
  sessions,
12944
14794
  setLangfuseTraceIdInBaggage,
12945
14795
  trace,
14796
+ unstable,
12946
14797
  utils
12947
14798
  });
12948
14799
  //# sourceMappingURL=index.cjs.map