@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.cjs +2192 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2996 -349
- package/dist/index.d.ts +2996 -349
- package/dist/index.mjs +2188 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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,
|
|
@@ -103,10 +105,12 @@ __export(index_exports, {
|
|
|
103
105
|
scim: () => scim_exports,
|
|
104
106
|
scoreConfigs: () => scoreConfigs_exports,
|
|
105
107
|
scores: () => scores_exports,
|
|
108
|
+
scoresV3: () => scoresV3_exports,
|
|
106
109
|
serializeValue: () => serializeValue,
|
|
107
110
|
sessions: () => sessions_exports,
|
|
108
111
|
setLangfuseTraceIdInBaggage: () => setLangfuseTraceIdInBaggage,
|
|
109
112
|
trace: () => trace_exports,
|
|
113
|
+
unstable: () => unstable_exports,
|
|
110
114
|
utils: () => utils_exports
|
|
111
115
|
});
|
|
112
116
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -383,7 +387,7 @@ var resetGlobalLogger = () => {
|
|
|
383
387
|
// package.json
|
|
384
388
|
var package_default = {
|
|
385
389
|
name: "@langfuse/core",
|
|
386
|
-
version: "5.
|
|
390
|
+
version: "5.5.0-beta.0",
|
|
387
391
|
description: "Core functions and utilities for Langfuse packages",
|
|
388
392
|
type: "module",
|
|
389
393
|
sideEffects: false,
|
|
@@ -492,8 +496,10 @@ var AnnotationQueueObjectType = {
|
|
|
492
496
|
// src/api/api/resources/blobStorageIntegrations/index.ts
|
|
493
497
|
var blobStorageIntegrations_exports = {};
|
|
494
498
|
__export(blobStorageIntegrations_exports, {
|
|
499
|
+
BlobStorageExportFieldGroup: () => BlobStorageExportFieldGroup,
|
|
495
500
|
BlobStorageExportFrequency: () => BlobStorageExportFrequency,
|
|
496
501
|
BlobStorageExportMode: () => BlobStorageExportMode,
|
|
502
|
+
BlobStorageExportSource: () => BlobStorageExportSource,
|
|
497
503
|
BlobStorageIntegrationFileType: () => BlobStorageIntegrationFileType,
|
|
498
504
|
BlobStorageIntegrationType: () => BlobStorageIntegrationType,
|
|
499
505
|
BlobStorageSyncStatus: () => BlobStorageSyncStatus
|
|
@@ -522,11 +528,34 @@ var BlobStorageExportMode = {
|
|
|
522
528
|
|
|
523
529
|
// src/api/api/resources/blobStorageIntegrations/types/BlobStorageExportFrequency.ts
|
|
524
530
|
var BlobStorageExportFrequency = {
|
|
531
|
+
Every20Minutes: "every_20_minutes",
|
|
525
532
|
Hourly: "hourly",
|
|
526
533
|
Daily: "daily",
|
|
527
534
|
Weekly: "weekly"
|
|
528
535
|
};
|
|
529
536
|
|
|
537
|
+
// src/api/api/resources/blobStorageIntegrations/types/BlobStorageExportSource.ts
|
|
538
|
+
var BlobStorageExportSource = {
|
|
539
|
+
LegacyTracesObservations: "LEGACY_TRACES_OBSERVATIONS",
|
|
540
|
+
ObservationsV2: "OBSERVATIONS_V2",
|
|
541
|
+
LegacyTracesAndEnrichedObservations: "LEGACY_TRACES_AND_ENRICHED_OBSERVATIONS"
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
// src/api/api/resources/blobStorageIntegrations/types/BlobStorageExportFieldGroup.ts
|
|
545
|
+
var BlobStorageExportFieldGroup = {
|
|
546
|
+
Core: "core",
|
|
547
|
+
Basic: "basic",
|
|
548
|
+
Time: "time",
|
|
549
|
+
Io: "io",
|
|
550
|
+
Metadata: "metadata",
|
|
551
|
+
Model: "model",
|
|
552
|
+
Usage: "usage",
|
|
553
|
+
Prompt: "prompt",
|
|
554
|
+
Metrics: "metrics",
|
|
555
|
+
Tools: "tools",
|
|
556
|
+
TraceContext: "trace_context"
|
|
557
|
+
};
|
|
558
|
+
|
|
530
559
|
// src/api/api/resources/blobStorageIntegrations/types/BlobStorageSyncStatus.ts
|
|
531
560
|
var BlobStorageSyncStatus = {
|
|
532
561
|
Idle: "idle",
|
|
@@ -787,6 +816,7 @@ var ObservationType = {
|
|
|
787
816
|
// src/api/api/resources/legacy/index.ts
|
|
788
817
|
var legacy_exports = {};
|
|
789
818
|
__export(legacy_exports, {
|
|
819
|
+
CreateScoreSource: () => CreateScoreSource,
|
|
790
820
|
metricsV1: () => metricsV1_exports,
|
|
791
821
|
observationsV1: () => observationsV1_exports,
|
|
792
822
|
scoreV1: () => scoreV1_exports
|
|
@@ -800,6 +830,15 @@ var observationsV1_exports = {};
|
|
|
800
830
|
|
|
801
831
|
// src/api/api/resources/legacy/resources/scoreV1/index.ts
|
|
802
832
|
var scoreV1_exports = {};
|
|
833
|
+
__export(scoreV1_exports, {
|
|
834
|
+
CreateScoreSource: () => CreateScoreSource
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
// src/api/api/resources/legacy/resources/scoreV1/types/CreateScoreSource.ts
|
|
838
|
+
var CreateScoreSource = {
|
|
839
|
+
Api: "API",
|
|
840
|
+
Annotation: "ANNOTATION"
|
|
841
|
+
};
|
|
803
842
|
|
|
804
843
|
// src/api/api/resources/llmConnections/index.ts
|
|
805
844
|
var llmConnections_exports = {};
|
|
@@ -950,6 +989,9 @@ var scim_exports = {};
|
|
|
950
989
|
// src/api/api/resources/scoreConfigs/index.ts
|
|
951
990
|
var scoreConfigs_exports = {};
|
|
952
991
|
|
|
992
|
+
// src/api/api/resources/scoresV3/index.ts
|
|
993
|
+
var scoresV3_exports = {};
|
|
994
|
+
|
|
953
995
|
// src/api/api/resources/scores/index.ts
|
|
954
996
|
var scores_exports = {};
|
|
955
997
|
|
|
@@ -959,6 +1001,315 @@ var sessions_exports = {};
|
|
|
959
1001
|
// src/api/api/resources/trace/index.ts
|
|
960
1002
|
var trace_exports = {};
|
|
961
1003
|
|
|
1004
|
+
// src/api/api/resources/unstable/index.ts
|
|
1005
|
+
var unstable_exports = {};
|
|
1006
|
+
__export(unstable_exports, {
|
|
1007
|
+
AccessDeniedError: () => AccessDeniedError2,
|
|
1008
|
+
BadRequestError: () => BadRequestError,
|
|
1009
|
+
CodeEvaluatorSourceCodeLanguage: () => CodeEvaluatorSourceCodeLanguage,
|
|
1010
|
+
ConflictError: () => ConflictError,
|
|
1011
|
+
EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator,
|
|
1012
|
+
EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator,
|
|
1013
|
+
EvaluationRuleMappingSource: () => EvaluationRuleMappingSource,
|
|
1014
|
+
EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator,
|
|
1015
|
+
EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator,
|
|
1016
|
+
EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator,
|
|
1017
|
+
EvaluationRuleStatus: () => EvaluationRuleStatus,
|
|
1018
|
+
EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator,
|
|
1019
|
+
EvaluationRuleTarget: () => EvaluationRuleTarget,
|
|
1020
|
+
EvaluatorOutputDataType: () => EvaluatorOutputDataType,
|
|
1021
|
+
EvaluatorScope: () => EvaluatorScope,
|
|
1022
|
+
EvaluatorType: () => EvaluatorType,
|
|
1023
|
+
InternalServerError: () => InternalServerError,
|
|
1024
|
+
LlmAsJudgeEvaluatorType: () => LlmAsJudgeEvaluatorType,
|
|
1025
|
+
MethodNotAllowedError: () => MethodNotAllowedError2,
|
|
1026
|
+
NotFoundError: () => NotFoundError2,
|
|
1027
|
+
PublicApiErrorCode: () => PublicApiErrorCode,
|
|
1028
|
+
TooManyRequestsError: () => TooManyRequestsError,
|
|
1029
|
+
UnauthorizedError: () => UnauthorizedError2,
|
|
1030
|
+
UnprocessableContentError: () => UnprocessableContentError,
|
|
1031
|
+
commons: () => commons_exports2,
|
|
1032
|
+
errors: () => errors_exports2,
|
|
1033
|
+
evaluationRules: () => evaluationRules_exports,
|
|
1034
|
+
evaluators: () => evaluators_exports
|
|
1035
|
+
});
|
|
1036
|
+
|
|
1037
|
+
// src/api/api/resources/unstable/resources/commons/index.ts
|
|
1038
|
+
var commons_exports2 = {};
|
|
1039
|
+
__export(commons_exports2, {
|
|
1040
|
+
CodeEvaluatorSourceCodeLanguage: () => CodeEvaluatorSourceCodeLanguage,
|
|
1041
|
+
EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator,
|
|
1042
|
+
EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator,
|
|
1043
|
+
EvaluationRuleMappingSource: () => EvaluationRuleMappingSource,
|
|
1044
|
+
EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator,
|
|
1045
|
+
EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator,
|
|
1046
|
+
EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator,
|
|
1047
|
+
EvaluationRuleStatus: () => EvaluationRuleStatus,
|
|
1048
|
+
EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator,
|
|
1049
|
+
EvaluationRuleTarget: () => EvaluationRuleTarget,
|
|
1050
|
+
EvaluatorOutputDataType: () => EvaluatorOutputDataType,
|
|
1051
|
+
EvaluatorScope: () => EvaluatorScope,
|
|
1052
|
+
EvaluatorType: () => EvaluatorType
|
|
1053
|
+
});
|
|
1054
|
+
|
|
1055
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluatorType.ts
|
|
1056
|
+
var EvaluatorType = {
|
|
1057
|
+
LlmAsJudge: "llm_as_judge",
|
|
1058
|
+
Code: "code"
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
// src/api/api/resources/unstable/resources/commons/types/CodeEvaluatorSourceCodeLanguage.ts
|
|
1062
|
+
var CodeEvaluatorSourceCodeLanguage = {
|
|
1063
|
+
Python: "PYTHON",
|
|
1064
|
+
Typescript: "TYPESCRIPT"
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluatorScope.ts
|
|
1068
|
+
var EvaluatorScope = {
|
|
1069
|
+
Project: "project",
|
|
1070
|
+
Managed: "managed"
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluationRuleTarget.ts
|
|
1074
|
+
var EvaluationRuleTarget = {
|
|
1075
|
+
Observation: "observation",
|
|
1076
|
+
Experiment: "experiment"
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStatus.ts
|
|
1080
|
+
var EvaluationRuleStatus = {
|
|
1081
|
+
Active: "active",
|
|
1082
|
+
Inactive: "inactive",
|
|
1083
|
+
Paused: "paused"
|
|
1084
|
+
};
|
|
1085
|
+
|
|
1086
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluationRuleMappingSource.ts
|
|
1087
|
+
var EvaluationRuleMappingSource = {
|
|
1088
|
+
Input: "input",
|
|
1089
|
+
Output: "output",
|
|
1090
|
+
Metadata: "metadata",
|
|
1091
|
+
ExpectedOutput: "expected_output",
|
|
1092
|
+
ExperimentItemMetadata: "experiment_item_metadata"
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluatorOutputDataType.ts
|
|
1096
|
+
var EvaluatorOutputDataType = {
|
|
1097
|
+
Numeric: "NUMERIC",
|
|
1098
|
+
Boolean: "BOOLEAN",
|
|
1099
|
+
Categorical: "CATEGORICAL"
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStringFilterOperator.ts
|
|
1103
|
+
var EvaluationRuleStringFilterOperator = {
|
|
1104
|
+
Equals: "=",
|
|
1105
|
+
Contains: "contains",
|
|
1106
|
+
DoesNotContain: "does not contain",
|
|
1107
|
+
StartsWith: "starts with",
|
|
1108
|
+
EndsWith: "ends with"
|
|
1109
|
+
};
|
|
1110
|
+
|
|
1111
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNumberFilterOperator.ts
|
|
1112
|
+
var EvaluationRuleNumberFilterOperator = {
|
|
1113
|
+
Equals: "=",
|
|
1114
|
+
GreaterThan: ">",
|
|
1115
|
+
LessThan: "<",
|
|
1116
|
+
GreaterThanOrEqual: ">=",
|
|
1117
|
+
LessThanOrEqual: "<="
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluationRuleOptionsFilterOperator.ts
|
|
1121
|
+
var EvaluationRuleOptionsFilterOperator = {
|
|
1122
|
+
AnyOf: "any of",
|
|
1123
|
+
NoneOf: "none of"
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluationRuleArrayOptionsFilterOperator.ts
|
|
1127
|
+
var EvaluationRuleArrayOptionsFilterOperator = {
|
|
1128
|
+
AnyOf: "any of",
|
|
1129
|
+
NoneOf: "none of",
|
|
1130
|
+
AllOf: "all of"
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1133
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluationRuleBooleanFilterOperator.ts
|
|
1134
|
+
var EvaluationRuleBooleanFilterOperator = {
|
|
1135
|
+
Equals: "=",
|
|
1136
|
+
NotEquals: "<>"
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
// src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNullFilterOperator.ts
|
|
1140
|
+
var EvaluationRuleNullFilterOperator = {
|
|
1141
|
+
IsNull: "is null",
|
|
1142
|
+
IsNotNull: "is not null"
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
// src/api/api/resources/unstable/resources/errors/index.ts
|
|
1146
|
+
var errors_exports2 = {};
|
|
1147
|
+
__export(errors_exports2, {
|
|
1148
|
+
AccessDeniedError: () => AccessDeniedError2,
|
|
1149
|
+
BadRequestError: () => BadRequestError,
|
|
1150
|
+
ConflictError: () => ConflictError,
|
|
1151
|
+
InternalServerError: () => InternalServerError,
|
|
1152
|
+
MethodNotAllowedError: () => MethodNotAllowedError2,
|
|
1153
|
+
NotFoundError: () => NotFoundError2,
|
|
1154
|
+
PublicApiErrorCode: () => PublicApiErrorCode,
|
|
1155
|
+
TooManyRequestsError: () => TooManyRequestsError,
|
|
1156
|
+
UnauthorizedError: () => UnauthorizedError2,
|
|
1157
|
+
UnprocessableContentError: () => UnprocessableContentError
|
|
1158
|
+
});
|
|
1159
|
+
|
|
1160
|
+
// src/api/api/resources/unstable/resources/errors/types/PublicApiErrorCode.ts
|
|
1161
|
+
var PublicApiErrorCode = {
|
|
1162
|
+
AuthenticationFailed: "authentication_failed",
|
|
1163
|
+
AccessDenied: "access_denied",
|
|
1164
|
+
InvalidRequest: "invalid_request",
|
|
1165
|
+
InvalidQuery: "invalid_query",
|
|
1166
|
+
InvalidBody: "invalid_body",
|
|
1167
|
+
InvalidFilterValue: "invalid_filter_value",
|
|
1168
|
+
InvalidJsonPath: "invalid_json_path",
|
|
1169
|
+
InvalidVariableMapping: "invalid_variable_mapping",
|
|
1170
|
+
MissingVariableMapping: "missing_variable_mapping",
|
|
1171
|
+
DuplicateVariableMapping: "duplicate_variable_mapping",
|
|
1172
|
+
ResourceNotFound: "resource_not_found",
|
|
1173
|
+
NameConflict: "name_conflict",
|
|
1174
|
+
EvaluatorPreflightFailed: "evaluator_preflight_failed",
|
|
1175
|
+
Conflict: "conflict",
|
|
1176
|
+
UnprocessableContent: "unprocessable_content",
|
|
1177
|
+
RateLimited: "rate_limited",
|
|
1178
|
+
MethodNotAllowed: "method_not_allowed",
|
|
1179
|
+
InternalError: "internal_error"
|
|
1180
|
+
};
|
|
1181
|
+
|
|
1182
|
+
// src/api/api/resources/unstable/resources/errors/errors/BadRequestError.ts
|
|
1183
|
+
var BadRequestError = class _BadRequestError extends LangfuseAPIError {
|
|
1184
|
+
constructor(body, rawResponse) {
|
|
1185
|
+
super({
|
|
1186
|
+
message: "BadRequestError",
|
|
1187
|
+
statusCode: 400,
|
|
1188
|
+
body,
|
|
1189
|
+
rawResponse
|
|
1190
|
+
});
|
|
1191
|
+
Object.setPrototypeOf(this, _BadRequestError.prototype);
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
// src/api/api/resources/unstable/resources/errors/errors/UnauthorizedError.ts
|
|
1196
|
+
var UnauthorizedError2 = class _UnauthorizedError extends LangfuseAPIError {
|
|
1197
|
+
constructor(body, rawResponse) {
|
|
1198
|
+
super({
|
|
1199
|
+
message: "UnauthorizedError",
|
|
1200
|
+
statusCode: 401,
|
|
1201
|
+
body,
|
|
1202
|
+
rawResponse
|
|
1203
|
+
});
|
|
1204
|
+
Object.setPrototypeOf(this, _UnauthorizedError.prototype);
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
// src/api/api/resources/unstable/resources/errors/errors/AccessDeniedError.ts
|
|
1209
|
+
var AccessDeniedError2 = class _AccessDeniedError extends LangfuseAPIError {
|
|
1210
|
+
constructor(body, rawResponse) {
|
|
1211
|
+
super({
|
|
1212
|
+
message: "AccessDeniedError",
|
|
1213
|
+
statusCode: 403,
|
|
1214
|
+
body,
|
|
1215
|
+
rawResponse
|
|
1216
|
+
});
|
|
1217
|
+
Object.setPrototypeOf(this, _AccessDeniedError.prototype);
|
|
1218
|
+
}
|
|
1219
|
+
};
|
|
1220
|
+
|
|
1221
|
+
// src/api/api/resources/unstable/resources/errors/errors/NotFoundError.ts
|
|
1222
|
+
var NotFoundError2 = class _NotFoundError extends LangfuseAPIError {
|
|
1223
|
+
constructor(body, rawResponse) {
|
|
1224
|
+
super({
|
|
1225
|
+
message: "NotFoundError",
|
|
1226
|
+
statusCode: 404,
|
|
1227
|
+
body,
|
|
1228
|
+
rawResponse
|
|
1229
|
+
});
|
|
1230
|
+
Object.setPrototypeOf(this, _NotFoundError.prototype);
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
|
|
1234
|
+
// src/api/api/resources/unstable/resources/errors/errors/MethodNotAllowedError.ts
|
|
1235
|
+
var MethodNotAllowedError2 = class _MethodNotAllowedError extends LangfuseAPIError {
|
|
1236
|
+
constructor(body, rawResponse) {
|
|
1237
|
+
super({
|
|
1238
|
+
message: "MethodNotAllowedError",
|
|
1239
|
+
statusCode: 405,
|
|
1240
|
+
body,
|
|
1241
|
+
rawResponse
|
|
1242
|
+
});
|
|
1243
|
+
Object.setPrototypeOf(this, _MethodNotAllowedError.prototype);
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
|
|
1247
|
+
// src/api/api/resources/unstable/resources/errors/errors/ConflictError.ts
|
|
1248
|
+
var ConflictError = class _ConflictError extends LangfuseAPIError {
|
|
1249
|
+
constructor(body, rawResponse) {
|
|
1250
|
+
super({
|
|
1251
|
+
message: "ConflictError",
|
|
1252
|
+
statusCode: 409,
|
|
1253
|
+
body,
|
|
1254
|
+
rawResponse
|
|
1255
|
+
});
|
|
1256
|
+
Object.setPrototypeOf(this, _ConflictError.prototype);
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
|
|
1260
|
+
// src/api/api/resources/unstable/resources/errors/errors/UnprocessableContentError.ts
|
|
1261
|
+
var UnprocessableContentError = class _UnprocessableContentError extends LangfuseAPIError {
|
|
1262
|
+
constructor(body, rawResponse) {
|
|
1263
|
+
super({
|
|
1264
|
+
message: "UnprocessableContentError",
|
|
1265
|
+
statusCode: 422,
|
|
1266
|
+
body,
|
|
1267
|
+
rawResponse
|
|
1268
|
+
});
|
|
1269
|
+
Object.setPrototypeOf(this, _UnprocessableContentError.prototype);
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
|
|
1273
|
+
// src/api/api/resources/unstable/resources/errors/errors/TooManyRequestsError.ts
|
|
1274
|
+
var TooManyRequestsError = class _TooManyRequestsError extends LangfuseAPIError {
|
|
1275
|
+
constructor(body, rawResponse) {
|
|
1276
|
+
super({
|
|
1277
|
+
message: "TooManyRequestsError",
|
|
1278
|
+
statusCode: 429,
|
|
1279
|
+
body,
|
|
1280
|
+
rawResponse
|
|
1281
|
+
});
|
|
1282
|
+
Object.setPrototypeOf(this, _TooManyRequestsError.prototype);
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
// src/api/api/resources/unstable/resources/errors/errors/InternalServerError.ts
|
|
1287
|
+
var InternalServerError = class _InternalServerError extends LangfuseAPIError {
|
|
1288
|
+
constructor(body, rawResponse) {
|
|
1289
|
+
super({
|
|
1290
|
+
message: "InternalServerError",
|
|
1291
|
+
statusCode: 500,
|
|
1292
|
+
body,
|
|
1293
|
+
rawResponse
|
|
1294
|
+
});
|
|
1295
|
+
Object.setPrototypeOf(this, _InternalServerError.prototype);
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
// src/api/api/resources/unstable/resources/evaluationRules/index.ts
|
|
1300
|
+
var evaluationRules_exports = {};
|
|
1301
|
+
__export(evaluationRules_exports, {
|
|
1302
|
+
LlmAsJudgeEvaluatorType: () => LlmAsJudgeEvaluatorType
|
|
1303
|
+
});
|
|
1304
|
+
|
|
1305
|
+
// src/api/api/resources/unstable/resources/evaluationRules/types/LlmAsJudgeEvaluatorType.ts
|
|
1306
|
+
var LlmAsJudgeEvaluatorType = {
|
|
1307
|
+
LlmAsJudge: "llm_as_judge"
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1310
|
+
// src/api/api/resources/unstable/resources/evaluators/index.ts
|
|
1311
|
+
var evaluators_exports = {};
|
|
1312
|
+
|
|
962
1313
|
// src/api/api/resources/utils/index.ts
|
|
963
1314
|
var utils_exports = {};
|
|
964
1315
|
__export(utils_exports, {
|
|
@@ -2944,13 +3295,15 @@ var BlobStorageIntegrations = class {
|
|
|
2944
3295
|
* accessKeyId: undefined,
|
|
2945
3296
|
* secretAccessKey: undefined,
|
|
2946
3297
|
* prefix: undefined,
|
|
2947
|
-
* exportFrequency: "
|
|
3298
|
+
* exportFrequency: "every_20_minutes",
|
|
2948
3299
|
* enabled: true,
|
|
2949
3300
|
* forcePathStyle: true,
|
|
2950
3301
|
* fileType: "JSON",
|
|
2951
3302
|
* exportMode: "FULL_HISTORY",
|
|
2952
3303
|
* exportStartDate: undefined,
|
|
2953
|
-
* compressed: undefined
|
|
3304
|
+
* compressed: undefined,
|
|
3305
|
+
* exportSource: undefined,
|
|
3306
|
+
* exportFieldGroups: undefined
|
|
2954
3307
|
* })
|
|
2955
3308
|
*/
|
|
2956
3309
|
upsertBlobStorageIntegration(request, requestOptions) {
|
|
@@ -5754,7 +6107,8 @@ var ScoreV1 = class {
|
|
|
5754
6107
|
* environment: undefined,
|
|
5755
6108
|
* queueId: undefined,
|
|
5756
6109
|
* dataType: undefined,
|
|
5757
|
-
* configId: undefined
|
|
6110
|
+
* configId: undefined,
|
|
6111
|
+
* source: undefined
|
|
5758
6112
|
* })
|
|
5759
6113
|
*/
|
|
5760
6114
|
create(request, requestOptions) {
|
|
@@ -6211,6 +6565,109 @@ var LlmConnections = class {
|
|
|
6211
6565
|
});
|
|
6212
6566
|
}
|
|
6213
6567
|
}
|
|
6568
|
+
/**
|
|
6569
|
+
* Delete an LLM connection by id. Evaluators that depend on the deleted connection are automatically paused.
|
|
6570
|
+
*
|
|
6571
|
+
* @param {string} id
|
|
6572
|
+
* @param {LlmConnections.RequestOptions} requestOptions - Request-specific configuration.
|
|
6573
|
+
*
|
|
6574
|
+
* @throws {@link LangfuseAPI.Error}
|
|
6575
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
6576
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
6577
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
6578
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
6579
|
+
*
|
|
6580
|
+
* @example
|
|
6581
|
+
* await client.llmConnections.delete("id")
|
|
6582
|
+
*/
|
|
6583
|
+
delete(id, requestOptions) {
|
|
6584
|
+
return HttpResponsePromise.fromPromise(
|
|
6585
|
+
this.__delete(id, requestOptions)
|
|
6586
|
+
);
|
|
6587
|
+
}
|
|
6588
|
+
async __delete(id, requestOptions) {
|
|
6589
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
6590
|
+
let _headers = mergeHeaders(
|
|
6591
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
6592
|
+
mergeOnlyDefinedHeaders({
|
|
6593
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
6594
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
6595
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
6596
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
6597
|
+
}),
|
|
6598
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
6599
|
+
);
|
|
6600
|
+
const _response = await fetcher({
|
|
6601
|
+
url: url_exports.join(
|
|
6602
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
6603
|
+
`/api/public/llm-connections/${encodeURIComponent(id)}`
|
|
6604
|
+
),
|
|
6605
|
+
method: "DELETE",
|
|
6606
|
+
headers: _headers,
|
|
6607
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
6608
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
6609
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
6610
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
6611
|
+
});
|
|
6612
|
+
if (_response.ok) {
|
|
6613
|
+
return {
|
|
6614
|
+
data: _response.body,
|
|
6615
|
+
rawResponse: _response.rawResponse
|
|
6616
|
+
};
|
|
6617
|
+
}
|
|
6618
|
+
if (_response.error.reason === "status-code") {
|
|
6619
|
+
switch (_response.error.statusCode) {
|
|
6620
|
+
case 400:
|
|
6621
|
+
throw new Error2(
|
|
6622
|
+
_response.error.body,
|
|
6623
|
+
_response.rawResponse
|
|
6624
|
+
);
|
|
6625
|
+
case 401:
|
|
6626
|
+
throw new UnauthorizedError(
|
|
6627
|
+
_response.error.body,
|
|
6628
|
+
_response.rawResponse
|
|
6629
|
+
);
|
|
6630
|
+
case 403:
|
|
6631
|
+
throw new AccessDeniedError(
|
|
6632
|
+
_response.error.body,
|
|
6633
|
+
_response.rawResponse
|
|
6634
|
+
);
|
|
6635
|
+
case 405:
|
|
6636
|
+
throw new MethodNotAllowedError(
|
|
6637
|
+
_response.error.body,
|
|
6638
|
+
_response.rawResponse
|
|
6639
|
+
);
|
|
6640
|
+
case 404:
|
|
6641
|
+
throw new NotFoundError(
|
|
6642
|
+
_response.error.body,
|
|
6643
|
+
_response.rawResponse
|
|
6644
|
+
);
|
|
6645
|
+
default:
|
|
6646
|
+
throw new LangfuseAPIError({
|
|
6647
|
+
statusCode: _response.error.statusCode,
|
|
6648
|
+
body: _response.error.body,
|
|
6649
|
+
rawResponse: _response.rawResponse
|
|
6650
|
+
});
|
|
6651
|
+
}
|
|
6652
|
+
}
|
|
6653
|
+
switch (_response.error.reason) {
|
|
6654
|
+
case "non-json":
|
|
6655
|
+
throw new LangfuseAPIError({
|
|
6656
|
+
statusCode: _response.error.statusCode,
|
|
6657
|
+
body: _response.error.rawBody,
|
|
6658
|
+
rawResponse: _response.rawResponse
|
|
6659
|
+
});
|
|
6660
|
+
case "timeout":
|
|
6661
|
+
throw new LangfuseAPITimeoutError(
|
|
6662
|
+
"Timeout exceeded when calling DELETE /api/public/llm-connections/{id}."
|
|
6663
|
+
);
|
|
6664
|
+
case "unknown":
|
|
6665
|
+
throw new LangfuseAPIError({
|
|
6666
|
+
message: _response.error.errorMessage,
|
|
6667
|
+
rawResponse: _response.rawResponse
|
|
6668
|
+
});
|
|
6669
|
+
}
|
|
6670
|
+
}
|
|
6214
6671
|
async _getAuthorizationHeader() {
|
|
6215
6672
|
const username = await Supplier.get(this._options.username);
|
|
6216
6673
|
const password = await Supplier.get(this._options.password);
|
|
@@ -7261,9 +7718,10 @@ var Observations = class {
|
|
|
7261
7718
|
* - `io` - input, output
|
|
7262
7719
|
* - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
|
|
7263
7720
|
* - `model` - providedModelName, internalModelId, modelParameters
|
|
7264
|
-
* - `usage` - usageDetails, costDetails, totalCost
|
|
7721
|
+
* - `usage` - usageDetails, costDetails, totalCost, usagePricingTierName
|
|
7265
7722
|
* - `prompt` - promptId, promptName, promptVersion
|
|
7266
7723
|
* - `metrics` - latency, timeToFirstToken
|
|
7724
|
+
* - `trace_context` - tags, release, traceName
|
|
7267
7725
|
*
|
|
7268
7726
|
* If not specified, `core` and `basic` field groups are returned.
|
|
7269
7727
|
*
|
|
@@ -11091,16 +11549,26 @@ var ScoreConfigs = class {
|
|
|
11091
11549
|
}
|
|
11092
11550
|
};
|
|
11093
11551
|
|
|
11094
|
-
// src/api/api/resources/
|
|
11095
|
-
var
|
|
11552
|
+
// src/api/api/resources/scoresV3/client/Client.ts
|
|
11553
|
+
var ScoresV3 = class {
|
|
11096
11554
|
constructor(_options) {
|
|
11097
11555
|
this._options = _options;
|
|
11098
11556
|
}
|
|
11099
11557
|
/**
|
|
11100
|
-
* Get a list of scores
|
|
11558
|
+
* Get a list of scores with a polymorphic `value` field (v3).
|
|
11101
11559
|
*
|
|
11102
|
-
*
|
|
11103
|
-
*
|
|
11560
|
+
* This endpoint requires Langfuse v4 or later.
|
|
11561
|
+
*
|
|
11562
|
+
* The `value` field type depends on `dataType`:
|
|
11563
|
+
* - `NUMERIC` → number
|
|
11564
|
+
* - `BOOLEAN` → boolean
|
|
11565
|
+
* - `CATEGORICAL`, `TEXT`, `CORRECTION` → string
|
|
11566
|
+
*
|
|
11567
|
+
* Use the `fields` parameter to include optional field groups beyond the
|
|
11568
|
+
* default `core`. Unknown group names return HTTP 400.
|
|
11569
|
+
*
|
|
11570
|
+
* @param {LangfuseAPI.GetScoresV3Request} request
|
|
11571
|
+
* @param {ScoresV3.RequestOptions} requestOptions - Request-specific configuration.
|
|
11104
11572
|
*
|
|
11105
11573
|
* @throws {@link LangfuseAPI.Error}
|
|
11106
11574
|
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
@@ -11109,27 +11577,231 @@ var Scores = class {
|
|
|
11109
11577
|
* @throws {@link LangfuseAPI.NotFoundError}
|
|
11110
11578
|
*
|
|
11111
11579
|
* @example
|
|
11112
|
-
* await client.
|
|
11580
|
+
* await client.scoresV3.getManyV3()
|
|
11113
11581
|
*/
|
|
11114
|
-
|
|
11582
|
+
getManyV3(request = {}, requestOptions) {
|
|
11115
11583
|
return HttpResponsePromise.fromPromise(
|
|
11116
|
-
this.
|
|
11584
|
+
this.__getManyV3(request, requestOptions)
|
|
11117
11585
|
);
|
|
11118
11586
|
}
|
|
11119
|
-
async
|
|
11587
|
+
async __getManyV3(request = {}, requestOptions) {
|
|
11120
11588
|
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
11121
11589
|
const {
|
|
11122
|
-
page,
|
|
11123
11590
|
limit,
|
|
11124
|
-
|
|
11591
|
+
cursor,
|
|
11592
|
+
fields,
|
|
11593
|
+
id,
|
|
11125
11594
|
name,
|
|
11126
|
-
fromTimestamp,
|
|
11127
|
-
toTimestamp,
|
|
11128
|
-
environment,
|
|
11129
11595
|
source,
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11596
|
+
dataType,
|
|
11597
|
+
environment,
|
|
11598
|
+
configId,
|
|
11599
|
+
queueId,
|
|
11600
|
+
authorUserId,
|
|
11601
|
+
value,
|
|
11602
|
+
valueMin,
|
|
11603
|
+
valueMax,
|
|
11604
|
+
traceId,
|
|
11605
|
+
sessionId,
|
|
11606
|
+
observationId,
|
|
11607
|
+
experimentId,
|
|
11608
|
+
fromTimestamp,
|
|
11609
|
+
toTimestamp
|
|
11610
|
+
} = request;
|
|
11611
|
+
const _queryParams = {};
|
|
11612
|
+
if (limit != null) {
|
|
11613
|
+
_queryParams["limit"] = limit.toString();
|
|
11614
|
+
}
|
|
11615
|
+
if (cursor != null) {
|
|
11616
|
+
_queryParams["cursor"] = cursor;
|
|
11617
|
+
}
|
|
11618
|
+
if (fields != null) {
|
|
11619
|
+
_queryParams["fields"] = fields;
|
|
11620
|
+
}
|
|
11621
|
+
if (id != null) {
|
|
11622
|
+
_queryParams["id"] = id;
|
|
11623
|
+
}
|
|
11624
|
+
if (name != null) {
|
|
11625
|
+
_queryParams["name"] = name;
|
|
11626
|
+
}
|
|
11627
|
+
if (source != null) {
|
|
11628
|
+
_queryParams["source"] = source;
|
|
11629
|
+
}
|
|
11630
|
+
if (dataType != null) {
|
|
11631
|
+
_queryParams["dataType"] = dataType;
|
|
11632
|
+
}
|
|
11633
|
+
if (environment != null) {
|
|
11634
|
+
_queryParams["environment"] = environment;
|
|
11635
|
+
}
|
|
11636
|
+
if (configId != null) {
|
|
11637
|
+
_queryParams["configId"] = configId;
|
|
11638
|
+
}
|
|
11639
|
+
if (queueId != null) {
|
|
11640
|
+
_queryParams["queueId"] = queueId;
|
|
11641
|
+
}
|
|
11642
|
+
if (authorUserId != null) {
|
|
11643
|
+
_queryParams["authorUserId"] = authorUserId;
|
|
11644
|
+
}
|
|
11645
|
+
if (value != null) {
|
|
11646
|
+
_queryParams["value"] = value;
|
|
11647
|
+
}
|
|
11648
|
+
if (valueMin != null) {
|
|
11649
|
+
_queryParams["valueMin"] = valueMin.toString();
|
|
11650
|
+
}
|
|
11651
|
+
if (valueMax != null) {
|
|
11652
|
+
_queryParams["valueMax"] = valueMax.toString();
|
|
11653
|
+
}
|
|
11654
|
+
if (traceId != null) {
|
|
11655
|
+
_queryParams["traceId"] = traceId;
|
|
11656
|
+
}
|
|
11657
|
+
if (sessionId != null) {
|
|
11658
|
+
_queryParams["sessionId"] = sessionId;
|
|
11659
|
+
}
|
|
11660
|
+
if (observationId != null) {
|
|
11661
|
+
_queryParams["observationId"] = observationId;
|
|
11662
|
+
}
|
|
11663
|
+
if (experimentId != null) {
|
|
11664
|
+
_queryParams["experimentId"] = experimentId;
|
|
11665
|
+
}
|
|
11666
|
+
if (fromTimestamp != null) {
|
|
11667
|
+
_queryParams["fromTimestamp"] = fromTimestamp;
|
|
11668
|
+
}
|
|
11669
|
+
if (toTimestamp != null) {
|
|
11670
|
+
_queryParams["toTimestamp"] = toTimestamp;
|
|
11671
|
+
}
|
|
11672
|
+
let _headers = mergeHeaders(
|
|
11673
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
11674
|
+
mergeOnlyDefinedHeaders({
|
|
11675
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
11676
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
11677
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
11678
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
11679
|
+
}),
|
|
11680
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
11681
|
+
);
|
|
11682
|
+
const _response = await fetcher({
|
|
11683
|
+
url: url_exports.join(
|
|
11684
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
11685
|
+
"/api/public/v3/scores"
|
|
11686
|
+
),
|
|
11687
|
+
method: "GET",
|
|
11688
|
+
headers: _headers,
|
|
11689
|
+
queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
|
|
11690
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
11691
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
11692
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
11693
|
+
});
|
|
11694
|
+
if (_response.ok) {
|
|
11695
|
+
return {
|
|
11696
|
+
data: _response.body,
|
|
11697
|
+
rawResponse: _response.rawResponse
|
|
11698
|
+
};
|
|
11699
|
+
}
|
|
11700
|
+
if (_response.error.reason === "status-code") {
|
|
11701
|
+
switch (_response.error.statusCode) {
|
|
11702
|
+
case 400:
|
|
11703
|
+
throw new Error2(
|
|
11704
|
+
_response.error.body,
|
|
11705
|
+
_response.rawResponse
|
|
11706
|
+
);
|
|
11707
|
+
case 401:
|
|
11708
|
+
throw new UnauthorizedError(
|
|
11709
|
+
_response.error.body,
|
|
11710
|
+
_response.rawResponse
|
|
11711
|
+
);
|
|
11712
|
+
case 403:
|
|
11713
|
+
throw new AccessDeniedError(
|
|
11714
|
+
_response.error.body,
|
|
11715
|
+
_response.rawResponse
|
|
11716
|
+
);
|
|
11717
|
+
case 405:
|
|
11718
|
+
throw new MethodNotAllowedError(
|
|
11719
|
+
_response.error.body,
|
|
11720
|
+
_response.rawResponse
|
|
11721
|
+
);
|
|
11722
|
+
case 404:
|
|
11723
|
+
throw new NotFoundError(
|
|
11724
|
+
_response.error.body,
|
|
11725
|
+
_response.rawResponse
|
|
11726
|
+
);
|
|
11727
|
+
default:
|
|
11728
|
+
throw new LangfuseAPIError({
|
|
11729
|
+
statusCode: _response.error.statusCode,
|
|
11730
|
+
body: _response.error.body,
|
|
11731
|
+
rawResponse: _response.rawResponse
|
|
11732
|
+
});
|
|
11733
|
+
}
|
|
11734
|
+
}
|
|
11735
|
+
switch (_response.error.reason) {
|
|
11736
|
+
case "non-json":
|
|
11737
|
+
throw new LangfuseAPIError({
|
|
11738
|
+
statusCode: _response.error.statusCode,
|
|
11739
|
+
body: _response.error.rawBody,
|
|
11740
|
+
rawResponse: _response.rawResponse
|
|
11741
|
+
});
|
|
11742
|
+
case "timeout":
|
|
11743
|
+
throw new LangfuseAPITimeoutError(
|
|
11744
|
+
"Timeout exceeded when calling GET /api/public/v3/scores."
|
|
11745
|
+
);
|
|
11746
|
+
case "unknown":
|
|
11747
|
+
throw new LangfuseAPIError({
|
|
11748
|
+
message: _response.error.errorMessage,
|
|
11749
|
+
rawResponse: _response.rawResponse
|
|
11750
|
+
});
|
|
11751
|
+
}
|
|
11752
|
+
}
|
|
11753
|
+
async _getAuthorizationHeader() {
|
|
11754
|
+
const username = await Supplier.get(this._options.username);
|
|
11755
|
+
const password = await Supplier.get(this._options.password);
|
|
11756
|
+
if (username != null && password != null) {
|
|
11757
|
+
return BasicAuth.toAuthorizationHeader({
|
|
11758
|
+
username,
|
|
11759
|
+
password
|
|
11760
|
+
});
|
|
11761
|
+
}
|
|
11762
|
+
return void 0;
|
|
11763
|
+
}
|
|
11764
|
+
};
|
|
11765
|
+
|
|
11766
|
+
// src/api/api/resources/scores/client/Client.ts
|
|
11767
|
+
var Scores = class {
|
|
11768
|
+
constructor(_options) {
|
|
11769
|
+
this._options = _options;
|
|
11770
|
+
}
|
|
11771
|
+
/**
|
|
11772
|
+
* Get a list of scores (supports both trace and session scores)
|
|
11773
|
+
*
|
|
11774
|
+
* @param {LangfuseAPI.GetScoresRequest} request
|
|
11775
|
+
* @param {Scores.RequestOptions} requestOptions - Request-specific configuration.
|
|
11776
|
+
*
|
|
11777
|
+
* @throws {@link LangfuseAPI.Error}
|
|
11778
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
11779
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
11780
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
11781
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
11782
|
+
*
|
|
11783
|
+
* @example
|
|
11784
|
+
* await client.scores.getMany()
|
|
11785
|
+
*/
|
|
11786
|
+
getMany(request = {}, requestOptions) {
|
|
11787
|
+
return HttpResponsePromise.fromPromise(
|
|
11788
|
+
this.__getMany(request, requestOptions)
|
|
11789
|
+
);
|
|
11790
|
+
}
|
|
11791
|
+
async __getMany(request = {}, requestOptions) {
|
|
11792
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
11793
|
+
const {
|
|
11794
|
+
page,
|
|
11795
|
+
limit,
|
|
11796
|
+
userId,
|
|
11797
|
+
name,
|
|
11798
|
+
fromTimestamp,
|
|
11799
|
+
toTimestamp,
|
|
11800
|
+
environment,
|
|
11801
|
+
source,
|
|
11802
|
+
operator,
|
|
11803
|
+
value,
|
|
11804
|
+
scoreIds,
|
|
11133
11805
|
configId,
|
|
11134
11806
|
sessionId,
|
|
11135
11807
|
datasetRunId,
|
|
@@ -12163,41 +12835,1496 @@ var Trace = class {
|
|
|
12163
12835
|
}
|
|
12164
12836
|
};
|
|
12165
12837
|
|
|
12166
|
-
// src/api/Client.ts
|
|
12167
|
-
var
|
|
12838
|
+
// src/api/api/resources/unstable/resources/evaluationRules/client/Client.ts
|
|
12839
|
+
var EvaluationRules = class {
|
|
12168
12840
|
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);
|
|
12841
|
+
this._options = _options;
|
|
12184
12842
|
}
|
|
12185
|
-
|
|
12186
|
-
|
|
12187
|
-
|
|
12188
|
-
|
|
12843
|
+
/**
|
|
12844
|
+
* Create an evaluation rule.
|
|
12845
|
+
*
|
|
12846
|
+
* An evaluation rule defines **what** incoming data should be evaluated and **how prompt variables should be populated** from that data.
|
|
12847
|
+
*
|
|
12848
|
+
* Use this resource after choosing an evaluator from the evaluator endpoints.
|
|
12849
|
+
*
|
|
12850
|
+
* Key rules:
|
|
12851
|
+
* - `name` must be unique within the project for public evaluation rules
|
|
12852
|
+
* - `target` must be `observation` or `experiment`
|
|
12853
|
+
* - `evaluator.name` + `evaluator.scope` must identify an existing evaluator family returned by the evaluator endpoints
|
|
12854
|
+
* - Langfuse resolves that family to its latest version before saving the evaluation rule
|
|
12855
|
+
* - for `target=experiment`, use dataset `id` values from `GET /api/public/v2/datasets` when filtering by `datasetId`
|
|
12856
|
+
* - for `llm_as_judge` evaluators, every evaluator prompt variable must be mapped exactly once
|
|
12857
|
+
* - for `code` evaluators, Langfuse uses the fixed code runtime mapping; omit `mapping` in create and update requests
|
|
12858
|
+
* - for user-provided `llm_as_judge` mappings, `expected_output` and `experiment_item_metadata` are only valid for `target=experiment`
|
|
12859
|
+
* - if `enabled=true`, Langfuse validates that the referenced evaluator can currently run
|
|
12860
|
+
* - at most 50 evaluation rules can be effectively active in one project at the same time
|
|
12861
|
+
*
|
|
12862
|
+
* If an evaluation rule with the same `name` already exists in the project, the API returns `409`.
|
|
12863
|
+
* In that case, update the existing resource with `PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}` instead of creating a second one.
|
|
12864
|
+
*
|
|
12865
|
+
* If enabling this resource would exceed the 50-active limit, the API also returns `409`.
|
|
12866
|
+
* In that case, disable or pause another active evaluation rule before enabling a new one.
|
|
12867
|
+
*
|
|
12868
|
+
* Current scope:
|
|
12869
|
+
* - evaluation rules are live-ingestion rules only
|
|
12870
|
+
* - they do not trigger historical backfills
|
|
12871
|
+
*
|
|
12872
|
+
* Recovery guidance:
|
|
12873
|
+
* - `400 invalid_filter_value`: fix the filter `column` or `value` using `details.column`, `details.invalidValues`, and `details.allowedValues`
|
|
12874
|
+
* - `400 invalid_filter_value` with `details.column=datasetId`: call `GET /api/public/v2/datasets`, then retry with dataset `id` values from that response
|
|
12875
|
+
* - `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`
|
|
12876
|
+
* - `400 duplicate_variable_mapping`: remove repeated mappings for the same variable
|
|
12877
|
+
* - `400 invalid_variable_mapping`: for `llm_as_judge`, switch to a valid `source` for the selected `target`, or fix the variable name
|
|
12878
|
+
* - `400 invalid_json_path`: remove or correct the `jsonPath`
|
|
12879
|
+
* - `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.
|
|
12880
|
+
*
|
|
12881
|
+
* @param {LangfuseAPI.unstable.CreateEvaluationRuleRequest} request
|
|
12882
|
+
* @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
|
|
12883
|
+
*
|
|
12884
|
+
* @throws {@link LangfuseAPI.unstable.BadRequestError}
|
|
12885
|
+
* @throws {@link LangfuseAPI.unstable.UnauthorizedError}
|
|
12886
|
+
* @throws {@link LangfuseAPI.unstable.AccessDeniedError}
|
|
12887
|
+
* @throws {@link LangfuseAPI.unstable.NotFoundError}
|
|
12888
|
+
* @throws {@link LangfuseAPI.unstable.ConflictError}
|
|
12889
|
+
* @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
|
|
12890
|
+
* @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
|
|
12891
|
+
* @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
|
|
12892
|
+
* @throws {@link LangfuseAPI.unstable.InternalServerError}
|
|
12893
|
+
* @throws {@link LangfuseAPI.Error}
|
|
12894
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
12895
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
12896
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
12897
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
12898
|
+
*
|
|
12899
|
+
* @example
|
|
12900
|
+
* await client.unstable.evaluationRules.create({
|
|
12901
|
+
* name: "answer-correctness-live",
|
|
12902
|
+
* evaluator: {
|
|
12903
|
+
* name: "answer-correctness",
|
|
12904
|
+
* scope: "project",
|
|
12905
|
+
* type: "llm_as_judge"
|
|
12906
|
+
* },
|
|
12907
|
+
* target: "observation",
|
|
12908
|
+
* enabled: true,
|
|
12909
|
+
* sampling: 1,
|
|
12910
|
+
* filter: [{
|
|
12911
|
+
* type: "stringOptions",
|
|
12912
|
+
* column: "type",
|
|
12913
|
+
* operator: "any of",
|
|
12914
|
+
* value: ["GENERATION"]
|
|
12915
|
+
* }],
|
|
12916
|
+
* mapping: [{
|
|
12917
|
+
* variable: "input",
|
|
12918
|
+
* source: "input"
|
|
12919
|
+
* }, {
|
|
12920
|
+
* variable: "output",
|
|
12921
|
+
* source: "output"
|
|
12922
|
+
* }]
|
|
12923
|
+
* })
|
|
12924
|
+
*
|
|
12925
|
+
* @example
|
|
12926
|
+
* await client.unstable.evaluationRules.create({
|
|
12927
|
+
* name: "toxicity-code-live",
|
|
12928
|
+
* evaluator: {
|
|
12929
|
+
* name: "toxicity-detector",
|
|
12930
|
+
* scope: "project",
|
|
12931
|
+
* type: "code"
|
|
12932
|
+
* },
|
|
12933
|
+
* target: "observation",
|
|
12934
|
+
* enabled: true,
|
|
12935
|
+
* sampling: 1,
|
|
12936
|
+
* filter: [{
|
|
12937
|
+
* type: "stringOptions",
|
|
12938
|
+
* column: "type",
|
|
12939
|
+
* operator: "any of",
|
|
12940
|
+
* value: ["GENERATION"]
|
|
12941
|
+
* }]
|
|
12942
|
+
* })
|
|
12943
|
+
*
|
|
12944
|
+
* @example
|
|
12945
|
+
* await client.unstable.evaluationRules.create({
|
|
12946
|
+
* name: "experiment-expected-output-match",
|
|
12947
|
+
* evaluator: {
|
|
12948
|
+
* name: "expected-output-match",
|
|
12949
|
+
* scope: "project",
|
|
12950
|
+
* type: "llm_as_judge"
|
|
12951
|
+
* },
|
|
12952
|
+
* target: "experiment",
|
|
12953
|
+
* enabled: true,
|
|
12954
|
+
* sampling: 0.5,
|
|
12955
|
+
* filter: [{
|
|
12956
|
+
* type: "stringOptions",
|
|
12957
|
+
* column: "datasetId",
|
|
12958
|
+
* operator: "any of",
|
|
12959
|
+
* value: ["550e8400-e29b-41d4-a716-446655440000"]
|
|
12960
|
+
* }],
|
|
12961
|
+
* mapping: [{
|
|
12962
|
+
* variable: "output",
|
|
12963
|
+
* source: "output"
|
|
12964
|
+
* }, {
|
|
12965
|
+
* variable: "expected_output",
|
|
12966
|
+
* source: "expected_output"
|
|
12967
|
+
* }]
|
|
12968
|
+
* })
|
|
12969
|
+
*/
|
|
12970
|
+
create(request, requestOptions) {
|
|
12971
|
+
return HttpResponsePromise.fromPromise(
|
|
12972
|
+
this.__create(request, requestOptions)
|
|
12189
12973
|
);
|
|
12190
12974
|
}
|
|
12191
|
-
|
|
12192
|
-
var _a2;
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
|
|
12975
|
+
async __create(request, requestOptions) {
|
|
12976
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
12977
|
+
let _headers = mergeHeaders(
|
|
12978
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
12979
|
+
mergeOnlyDefinedHeaders({
|
|
12980
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
12981
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
12982
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
12983
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
12984
|
+
}),
|
|
12985
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
12986
|
+
);
|
|
12987
|
+
const _response = await fetcher({
|
|
12988
|
+
url: url_exports.join(
|
|
12989
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
12990
|
+
"/api/public/unstable/evaluation-rules"
|
|
12991
|
+
),
|
|
12992
|
+
method: "POST",
|
|
12993
|
+
headers: _headers,
|
|
12994
|
+
contentType: "application/json",
|
|
12995
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
12996
|
+
requestType: "json",
|
|
12997
|
+
body: request,
|
|
12998
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
12999
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
13000
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
13001
|
+
});
|
|
13002
|
+
if (_response.ok) {
|
|
13003
|
+
return {
|
|
13004
|
+
data: _response.body,
|
|
13005
|
+
rawResponse: _response.rawResponse
|
|
13006
|
+
};
|
|
13007
|
+
}
|
|
13008
|
+
if (_response.error.reason === "status-code") {
|
|
13009
|
+
switch (_response.error.statusCode) {
|
|
13010
|
+
case 400:
|
|
13011
|
+
throw new unstable_exports.BadRequestError(
|
|
13012
|
+
_response.error.body,
|
|
13013
|
+
_response.rawResponse
|
|
13014
|
+
);
|
|
13015
|
+
case 401:
|
|
13016
|
+
throw new unstable_exports.UnauthorizedError(
|
|
13017
|
+
_response.error.body,
|
|
13018
|
+
_response.rawResponse
|
|
13019
|
+
);
|
|
13020
|
+
case 403:
|
|
13021
|
+
throw new unstable_exports.AccessDeniedError(
|
|
13022
|
+
_response.error.body,
|
|
13023
|
+
_response.rawResponse
|
|
13024
|
+
);
|
|
13025
|
+
case 404:
|
|
13026
|
+
throw new unstable_exports.NotFoundError(
|
|
13027
|
+
_response.error.body,
|
|
13028
|
+
_response.rawResponse
|
|
13029
|
+
);
|
|
13030
|
+
case 409:
|
|
13031
|
+
throw new unstable_exports.ConflictError(
|
|
13032
|
+
_response.error.body,
|
|
13033
|
+
_response.rawResponse
|
|
13034
|
+
);
|
|
13035
|
+
case 405:
|
|
13036
|
+
throw new unstable_exports.MethodNotAllowedError(
|
|
13037
|
+
_response.error.body,
|
|
13038
|
+
_response.rawResponse
|
|
13039
|
+
);
|
|
13040
|
+
case 422:
|
|
13041
|
+
throw new unstable_exports.UnprocessableContentError(
|
|
13042
|
+
_response.error.body,
|
|
13043
|
+
_response.rawResponse
|
|
13044
|
+
);
|
|
13045
|
+
case 429:
|
|
13046
|
+
throw new unstable_exports.TooManyRequestsError(
|
|
13047
|
+
_response.error.body,
|
|
13048
|
+
_response.rawResponse
|
|
13049
|
+
);
|
|
13050
|
+
case 500:
|
|
13051
|
+
throw new unstable_exports.InternalServerError(
|
|
13052
|
+
_response.error.body,
|
|
13053
|
+
_response.rawResponse
|
|
13054
|
+
);
|
|
13055
|
+
case 400:
|
|
13056
|
+
throw new Error2(
|
|
13057
|
+
_response.error.body,
|
|
13058
|
+
_response.rawResponse
|
|
13059
|
+
);
|
|
13060
|
+
case 401:
|
|
13061
|
+
throw new UnauthorizedError(
|
|
13062
|
+
_response.error.body,
|
|
13063
|
+
_response.rawResponse
|
|
13064
|
+
);
|
|
13065
|
+
case 403:
|
|
13066
|
+
throw new AccessDeniedError(
|
|
13067
|
+
_response.error.body,
|
|
13068
|
+
_response.rawResponse
|
|
13069
|
+
);
|
|
13070
|
+
case 405:
|
|
13071
|
+
throw new MethodNotAllowedError(
|
|
13072
|
+
_response.error.body,
|
|
13073
|
+
_response.rawResponse
|
|
13074
|
+
);
|
|
13075
|
+
case 404:
|
|
13076
|
+
throw new NotFoundError(
|
|
13077
|
+
_response.error.body,
|
|
13078
|
+
_response.rawResponse
|
|
13079
|
+
);
|
|
13080
|
+
default:
|
|
13081
|
+
throw new LangfuseAPIError({
|
|
13082
|
+
statusCode: _response.error.statusCode,
|
|
13083
|
+
body: _response.error.body,
|
|
13084
|
+
rawResponse: _response.rawResponse
|
|
13085
|
+
});
|
|
13086
|
+
}
|
|
13087
|
+
}
|
|
13088
|
+
switch (_response.error.reason) {
|
|
13089
|
+
case "non-json":
|
|
13090
|
+
throw new LangfuseAPIError({
|
|
13091
|
+
statusCode: _response.error.statusCode,
|
|
13092
|
+
body: _response.error.rawBody,
|
|
13093
|
+
rawResponse: _response.rawResponse
|
|
13094
|
+
});
|
|
13095
|
+
case "timeout":
|
|
13096
|
+
throw new LangfuseAPITimeoutError(
|
|
13097
|
+
"Timeout exceeded when calling POST /api/public/unstable/evaluation-rules."
|
|
13098
|
+
);
|
|
13099
|
+
case "unknown":
|
|
13100
|
+
throw new LangfuseAPIError({
|
|
13101
|
+
message: _response.error.errorMessage,
|
|
13102
|
+
rawResponse: _response.rawResponse
|
|
13103
|
+
});
|
|
13104
|
+
}
|
|
13105
|
+
}
|
|
13106
|
+
/**
|
|
13107
|
+
* List evaluation rules in the authenticated project.
|
|
13108
|
+
*
|
|
13109
|
+
* Each item describes one live evaluation rule and its effective runtime status.
|
|
13110
|
+
*
|
|
13111
|
+
* @param {LangfuseAPI.unstable.ListEvaluationRulesRequest} request
|
|
13112
|
+
* @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
|
|
13113
|
+
*
|
|
13114
|
+
* @throws {@link LangfuseAPI.unstable.BadRequestError}
|
|
13115
|
+
* @throws {@link LangfuseAPI.unstable.UnauthorizedError}
|
|
13116
|
+
* @throws {@link LangfuseAPI.unstable.AccessDeniedError}
|
|
13117
|
+
* @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
|
|
13118
|
+
* @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
|
|
13119
|
+
* @throws {@link LangfuseAPI.unstable.InternalServerError}
|
|
13120
|
+
* @throws {@link LangfuseAPI.Error}
|
|
13121
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
13122
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
13123
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
13124
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
13125
|
+
*
|
|
13126
|
+
* @example
|
|
13127
|
+
* await client.unstable.evaluationRules.list()
|
|
13128
|
+
*/
|
|
13129
|
+
list(request = {}, requestOptions) {
|
|
13130
|
+
return HttpResponsePromise.fromPromise(
|
|
13131
|
+
this.__list(request, requestOptions)
|
|
13132
|
+
);
|
|
13133
|
+
}
|
|
13134
|
+
async __list(request = {}, requestOptions) {
|
|
13135
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
13136
|
+
const { page, limit } = request;
|
|
13137
|
+
const _queryParams = {};
|
|
13138
|
+
if (page != null) {
|
|
13139
|
+
_queryParams["page"] = page.toString();
|
|
13140
|
+
}
|
|
13141
|
+
if (limit != null) {
|
|
13142
|
+
_queryParams["limit"] = limit.toString();
|
|
13143
|
+
}
|
|
13144
|
+
let _headers = mergeHeaders(
|
|
13145
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
13146
|
+
mergeOnlyDefinedHeaders({
|
|
13147
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
13148
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
13149
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
13150
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
13151
|
+
}),
|
|
13152
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
13153
|
+
);
|
|
13154
|
+
const _response = await fetcher({
|
|
13155
|
+
url: url_exports.join(
|
|
13156
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
13157
|
+
"/api/public/unstable/evaluation-rules"
|
|
13158
|
+
),
|
|
13159
|
+
method: "GET",
|
|
13160
|
+
headers: _headers,
|
|
13161
|
+
queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
|
|
13162
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
13163
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
13164
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
13165
|
+
});
|
|
13166
|
+
if (_response.ok) {
|
|
13167
|
+
return {
|
|
13168
|
+
data: _response.body,
|
|
13169
|
+
rawResponse: _response.rawResponse
|
|
13170
|
+
};
|
|
13171
|
+
}
|
|
13172
|
+
if (_response.error.reason === "status-code") {
|
|
13173
|
+
switch (_response.error.statusCode) {
|
|
13174
|
+
case 400:
|
|
13175
|
+
throw new unstable_exports.BadRequestError(
|
|
13176
|
+
_response.error.body,
|
|
13177
|
+
_response.rawResponse
|
|
13178
|
+
);
|
|
13179
|
+
case 401:
|
|
13180
|
+
throw new unstable_exports.UnauthorizedError(
|
|
13181
|
+
_response.error.body,
|
|
13182
|
+
_response.rawResponse
|
|
13183
|
+
);
|
|
13184
|
+
case 403:
|
|
13185
|
+
throw new unstable_exports.AccessDeniedError(
|
|
13186
|
+
_response.error.body,
|
|
13187
|
+
_response.rawResponse
|
|
13188
|
+
);
|
|
13189
|
+
case 405:
|
|
13190
|
+
throw new unstable_exports.MethodNotAllowedError(
|
|
13191
|
+
_response.error.body,
|
|
13192
|
+
_response.rawResponse
|
|
13193
|
+
);
|
|
13194
|
+
case 429:
|
|
13195
|
+
throw new unstable_exports.TooManyRequestsError(
|
|
13196
|
+
_response.error.body,
|
|
13197
|
+
_response.rawResponse
|
|
13198
|
+
);
|
|
13199
|
+
case 500:
|
|
13200
|
+
throw new unstable_exports.InternalServerError(
|
|
13201
|
+
_response.error.body,
|
|
13202
|
+
_response.rawResponse
|
|
13203
|
+
);
|
|
13204
|
+
case 400:
|
|
13205
|
+
throw new Error2(
|
|
13206
|
+
_response.error.body,
|
|
13207
|
+
_response.rawResponse
|
|
13208
|
+
);
|
|
13209
|
+
case 401:
|
|
13210
|
+
throw new UnauthorizedError(
|
|
13211
|
+
_response.error.body,
|
|
13212
|
+
_response.rawResponse
|
|
13213
|
+
);
|
|
13214
|
+
case 403:
|
|
13215
|
+
throw new AccessDeniedError(
|
|
13216
|
+
_response.error.body,
|
|
13217
|
+
_response.rawResponse
|
|
13218
|
+
);
|
|
13219
|
+
case 405:
|
|
13220
|
+
throw new MethodNotAllowedError(
|
|
13221
|
+
_response.error.body,
|
|
13222
|
+
_response.rawResponse
|
|
13223
|
+
);
|
|
13224
|
+
case 404:
|
|
13225
|
+
throw new NotFoundError(
|
|
13226
|
+
_response.error.body,
|
|
13227
|
+
_response.rawResponse
|
|
13228
|
+
);
|
|
13229
|
+
default:
|
|
13230
|
+
throw new LangfuseAPIError({
|
|
13231
|
+
statusCode: _response.error.statusCode,
|
|
13232
|
+
body: _response.error.body,
|
|
13233
|
+
rawResponse: _response.rawResponse
|
|
13234
|
+
});
|
|
13235
|
+
}
|
|
13236
|
+
}
|
|
13237
|
+
switch (_response.error.reason) {
|
|
13238
|
+
case "non-json":
|
|
13239
|
+
throw new LangfuseAPIError({
|
|
13240
|
+
statusCode: _response.error.statusCode,
|
|
13241
|
+
body: _response.error.rawBody,
|
|
13242
|
+
rawResponse: _response.rawResponse
|
|
13243
|
+
});
|
|
13244
|
+
case "timeout":
|
|
13245
|
+
throw new LangfuseAPITimeoutError(
|
|
13246
|
+
"Timeout exceeded when calling GET /api/public/unstable/evaluation-rules."
|
|
13247
|
+
);
|
|
13248
|
+
case "unknown":
|
|
13249
|
+
throw new LangfuseAPIError({
|
|
13250
|
+
message: _response.error.errorMessage,
|
|
13251
|
+
rawResponse: _response.rawResponse
|
|
13252
|
+
});
|
|
13253
|
+
}
|
|
13254
|
+
}
|
|
13255
|
+
/**
|
|
13256
|
+
* Get one evaluation rule by its identifier.
|
|
13257
|
+
*
|
|
13258
|
+
* Use this endpoint to inspect the current evaluator, target, mapping, filters, and effective runtime status.
|
|
13259
|
+
*
|
|
13260
|
+
* @param {string} evaluationRuleId - Evaluation rule identifier returned by the evaluation rule endpoints.
|
|
13261
|
+
* @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
|
|
13262
|
+
*
|
|
13263
|
+
* @throws {@link LangfuseAPI.unstable.BadRequestError}
|
|
13264
|
+
* @throws {@link LangfuseAPI.unstable.UnauthorizedError}
|
|
13265
|
+
* @throws {@link LangfuseAPI.unstable.AccessDeniedError}
|
|
13266
|
+
* @throws {@link LangfuseAPI.unstable.NotFoundError}
|
|
13267
|
+
* @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
|
|
13268
|
+
* @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
|
|
13269
|
+
* @throws {@link LangfuseAPI.unstable.InternalServerError}
|
|
13270
|
+
* @throws {@link LangfuseAPI.Error}
|
|
13271
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
13272
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
13273
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
13274
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
13275
|
+
*
|
|
13276
|
+
* @example
|
|
13277
|
+
* await client.unstable.evaluationRules.get("evaluationRuleId")
|
|
13278
|
+
*/
|
|
13279
|
+
get(evaluationRuleId, requestOptions) {
|
|
13280
|
+
return HttpResponsePromise.fromPromise(
|
|
13281
|
+
this.__get(evaluationRuleId, requestOptions)
|
|
13282
|
+
);
|
|
13283
|
+
}
|
|
13284
|
+
async __get(evaluationRuleId, requestOptions) {
|
|
13285
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
13286
|
+
let _headers = mergeHeaders(
|
|
13287
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
13288
|
+
mergeOnlyDefinedHeaders({
|
|
13289
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
13290
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
13291
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
13292
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
13293
|
+
}),
|
|
13294
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
13295
|
+
);
|
|
13296
|
+
const _response = await fetcher({
|
|
13297
|
+
url: url_exports.join(
|
|
13298
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
13299
|
+
`/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
|
|
13300
|
+
),
|
|
13301
|
+
method: "GET",
|
|
13302
|
+
headers: _headers,
|
|
13303
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
13304
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
13305
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
13306
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
13307
|
+
});
|
|
13308
|
+
if (_response.ok) {
|
|
13309
|
+
return {
|
|
13310
|
+
data: _response.body,
|
|
13311
|
+
rawResponse: _response.rawResponse
|
|
13312
|
+
};
|
|
13313
|
+
}
|
|
13314
|
+
if (_response.error.reason === "status-code") {
|
|
13315
|
+
switch (_response.error.statusCode) {
|
|
13316
|
+
case 400:
|
|
13317
|
+
throw new unstable_exports.BadRequestError(
|
|
13318
|
+
_response.error.body,
|
|
13319
|
+
_response.rawResponse
|
|
13320
|
+
);
|
|
13321
|
+
case 401:
|
|
13322
|
+
throw new unstable_exports.UnauthorizedError(
|
|
13323
|
+
_response.error.body,
|
|
13324
|
+
_response.rawResponse
|
|
13325
|
+
);
|
|
13326
|
+
case 403:
|
|
13327
|
+
throw new unstable_exports.AccessDeniedError(
|
|
13328
|
+
_response.error.body,
|
|
13329
|
+
_response.rawResponse
|
|
13330
|
+
);
|
|
13331
|
+
case 404:
|
|
13332
|
+
throw new unstable_exports.NotFoundError(
|
|
13333
|
+
_response.error.body,
|
|
13334
|
+
_response.rawResponse
|
|
13335
|
+
);
|
|
13336
|
+
case 405:
|
|
13337
|
+
throw new unstable_exports.MethodNotAllowedError(
|
|
13338
|
+
_response.error.body,
|
|
13339
|
+
_response.rawResponse
|
|
13340
|
+
);
|
|
13341
|
+
case 429:
|
|
13342
|
+
throw new unstable_exports.TooManyRequestsError(
|
|
13343
|
+
_response.error.body,
|
|
13344
|
+
_response.rawResponse
|
|
13345
|
+
);
|
|
13346
|
+
case 500:
|
|
13347
|
+
throw new unstable_exports.InternalServerError(
|
|
13348
|
+
_response.error.body,
|
|
13349
|
+
_response.rawResponse
|
|
13350
|
+
);
|
|
13351
|
+
case 400:
|
|
13352
|
+
throw new Error2(
|
|
13353
|
+
_response.error.body,
|
|
13354
|
+
_response.rawResponse
|
|
13355
|
+
);
|
|
13356
|
+
case 401:
|
|
13357
|
+
throw new UnauthorizedError(
|
|
13358
|
+
_response.error.body,
|
|
13359
|
+
_response.rawResponse
|
|
13360
|
+
);
|
|
13361
|
+
case 403:
|
|
13362
|
+
throw new AccessDeniedError(
|
|
13363
|
+
_response.error.body,
|
|
13364
|
+
_response.rawResponse
|
|
13365
|
+
);
|
|
13366
|
+
case 405:
|
|
13367
|
+
throw new MethodNotAllowedError(
|
|
13368
|
+
_response.error.body,
|
|
13369
|
+
_response.rawResponse
|
|
13370
|
+
);
|
|
13371
|
+
case 404:
|
|
13372
|
+
throw new NotFoundError(
|
|
13373
|
+
_response.error.body,
|
|
13374
|
+
_response.rawResponse
|
|
13375
|
+
);
|
|
13376
|
+
default:
|
|
13377
|
+
throw new LangfuseAPIError({
|
|
13378
|
+
statusCode: _response.error.statusCode,
|
|
13379
|
+
body: _response.error.body,
|
|
13380
|
+
rawResponse: _response.rawResponse
|
|
13381
|
+
});
|
|
13382
|
+
}
|
|
13383
|
+
}
|
|
13384
|
+
switch (_response.error.reason) {
|
|
13385
|
+
case "non-json":
|
|
13386
|
+
throw new LangfuseAPIError({
|
|
13387
|
+
statusCode: _response.error.statusCode,
|
|
13388
|
+
body: _response.error.rawBody,
|
|
13389
|
+
rawResponse: _response.rawResponse
|
|
13390
|
+
});
|
|
13391
|
+
case "timeout":
|
|
13392
|
+
throw new LangfuseAPITimeoutError(
|
|
13393
|
+
"Timeout exceeded when calling GET /api/public/unstable/evaluation-rules/{evaluationRuleId}."
|
|
13394
|
+
);
|
|
13395
|
+
case "unknown":
|
|
13396
|
+
throw new LangfuseAPIError({
|
|
13397
|
+
message: _response.error.errorMessage,
|
|
13398
|
+
rawResponse: _response.rawResponse
|
|
13399
|
+
});
|
|
13400
|
+
}
|
|
13401
|
+
}
|
|
13402
|
+
/**
|
|
13403
|
+
* Update an evaluation rule.
|
|
13404
|
+
*
|
|
13405
|
+
* Typical uses:
|
|
13406
|
+
* - enable or disable live execution
|
|
13407
|
+
* - switch to another evaluator
|
|
13408
|
+
* - adjust sampling
|
|
13409
|
+
* - change filters
|
|
13410
|
+
* - update LLM-as-judge variable mappings
|
|
13411
|
+
*
|
|
13412
|
+
* Important behavior:
|
|
13413
|
+
* - provide only the fields you want to change
|
|
13414
|
+
* - if you provide `evaluator`, Langfuse resolves that evaluator family to its latest version before saving
|
|
13415
|
+
* - changing `target`, `filter`, or an LLM-as-judge `mapping` must still produce a valid target-specific configuration
|
|
13416
|
+
* - 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
|
|
13417
|
+
* - for `code` evaluator rules, omit `mapping`; Langfuse stores the fixed code runtime mapping automatically
|
|
13418
|
+
* - if the resulting config is enabled, Langfuse re-validates that the selected evaluator can run
|
|
13419
|
+
* - 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`
|
|
13420
|
+
*
|
|
13421
|
+
* Recovery guidance:
|
|
13422
|
+
* - 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`
|
|
13423
|
+
* - if the update fails with `invalid_filter_value` after changing `target`, resend the request with a target-compatible `filter`
|
|
13424
|
+
*
|
|
13425
|
+
* @param {string} evaluationRuleId - Evaluation rule identifier.
|
|
13426
|
+
* @param {LangfuseAPI.unstable.UpdateEvaluationRuleRequest} request
|
|
13427
|
+
* @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
|
|
13428
|
+
*
|
|
13429
|
+
* @throws {@link LangfuseAPI.unstable.BadRequestError}
|
|
13430
|
+
* @throws {@link LangfuseAPI.unstable.UnauthorizedError}
|
|
13431
|
+
* @throws {@link LangfuseAPI.unstable.AccessDeniedError}
|
|
13432
|
+
* @throws {@link LangfuseAPI.unstable.NotFoundError}
|
|
13433
|
+
* @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
|
|
13434
|
+
* @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
|
|
13435
|
+
* @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
|
|
13436
|
+
* @throws {@link LangfuseAPI.unstable.InternalServerError}
|
|
13437
|
+
* @throws {@link LangfuseAPI.Error}
|
|
13438
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
13439
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
13440
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
13441
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
13442
|
+
*
|
|
13443
|
+
* @example
|
|
13444
|
+
* await client.unstable.evaluationRules.update("evaluationRuleId", {
|
|
13445
|
+
* name: undefined,
|
|
13446
|
+
* evaluator: undefined,
|
|
13447
|
+
* target: undefined,
|
|
13448
|
+
* enabled: undefined,
|
|
13449
|
+
* sampling: undefined,
|
|
13450
|
+
* filter: undefined,
|
|
13451
|
+
* mapping: undefined
|
|
13452
|
+
* })
|
|
13453
|
+
*/
|
|
13454
|
+
update(evaluationRuleId, request, requestOptions) {
|
|
13455
|
+
return HttpResponsePromise.fromPromise(
|
|
13456
|
+
this.__update(evaluationRuleId, request, requestOptions)
|
|
13457
|
+
);
|
|
13458
|
+
}
|
|
13459
|
+
async __update(evaluationRuleId, request, requestOptions) {
|
|
13460
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
13461
|
+
let _headers = mergeHeaders(
|
|
13462
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
13463
|
+
mergeOnlyDefinedHeaders({
|
|
13464
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
13465
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
13466
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
13467
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
13468
|
+
}),
|
|
13469
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
13470
|
+
);
|
|
13471
|
+
const _response = await fetcher({
|
|
13472
|
+
url: url_exports.join(
|
|
13473
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
13474
|
+
`/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
|
|
13475
|
+
),
|
|
13476
|
+
method: "PATCH",
|
|
13477
|
+
headers: _headers,
|
|
13478
|
+
contentType: "application/json",
|
|
13479
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
13480
|
+
requestType: "json",
|
|
13481
|
+
body: request,
|
|
13482
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
13483
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
13484
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
13485
|
+
});
|
|
13486
|
+
if (_response.ok) {
|
|
13487
|
+
return {
|
|
13488
|
+
data: _response.body,
|
|
13489
|
+
rawResponse: _response.rawResponse
|
|
13490
|
+
};
|
|
13491
|
+
}
|
|
13492
|
+
if (_response.error.reason === "status-code") {
|
|
13493
|
+
switch (_response.error.statusCode) {
|
|
13494
|
+
case 400:
|
|
13495
|
+
throw new unstable_exports.BadRequestError(
|
|
13496
|
+
_response.error.body,
|
|
13497
|
+
_response.rawResponse
|
|
13498
|
+
);
|
|
13499
|
+
case 401:
|
|
13500
|
+
throw new unstable_exports.UnauthorizedError(
|
|
13501
|
+
_response.error.body,
|
|
13502
|
+
_response.rawResponse
|
|
13503
|
+
);
|
|
13504
|
+
case 403:
|
|
13505
|
+
throw new unstable_exports.AccessDeniedError(
|
|
13506
|
+
_response.error.body,
|
|
13507
|
+
_response.rawResponse
|
|
13508
|
+
);
|
|
13509
|
+
case 404:
|
|
13510
|
+
throw new unstable_exports.NotFoundError(
|
|
13511
|
+
_response.error.body,
|
|
13512
|
+
_response.rawResponse
|
|
13513
|
+
);
|
|
13514
|
+
case 405:
|
|
13515
|
+
throw new unstable_exports.MethodNotAllowedError(
|
|
13516
|
+
_response.error.body,
|
|
13517
|
+
_response.rawResponse
|
|
13518
|
+
);
|
|
13519
|
+
case 422:
|
|
13520
|
+
throw new unstable_exports.UnprocessableContentError(
|
|
13521
|
+
_response.error.body,
|
|
13522
|
+
_response.rawResponse
|
|
13523
|
+
);
|
|
13524
|
+
case 429:
|
|
13525
|
+
throw new unstable_exports.TooManyRequestsError(
|
|
13526
|
+
_response.error.body,
|
|
13527
|
+
_response.rawResponse
|
|
13528
|
+
);
|
|
13529
|
+
case 500:
|
|
13530
|
+
throw new unstable_exports.InternalServerError(
|
|
13531
|
+
_response.error.body,
|
|
13532
|
+
_response.rawResponse
|
|
13533
|
+
);
|
|
13534
|
+
case 400:
|
|
13535
|
+
throw new Error2(
|
|
13536
|
+
_response.error.body,
|
|
13537
|
+
_response.rawResponse
|
|
13538
|
+
);
|
|
13539
|
+
case 401:
|
|
13540
|
+
throw new UnauthorizedError(
|
|
13541
|
+
_response.error.body,
|
|
13542
|
+
_response.rawResponse
|
|
13543
|
+
);
|
|
13544
|
+
case 403:
|
|
13545
|
+
throw new AccessDeniedError(
|
|
13546
|
+
_response.error.body,
|
|
13547
|
+
_response.rawResponse
|
|
13548
|
+
);
|
|
13549
|
+
case 405:
|
|
13550
|
+
throw new MethodNotAllowedError(
|
|
13551
|
+
_response.error.body,
|
|
13552
|
+
_response.rawResponse
|
|
13553
|
+
);
|
|
13554
|
+
case 404:
|
|
13555
|
+
throw new NotFoundError(
|
|
13556
|
+
_response.error.body,
|
|
13557
|
+
_response.rawResponse
|
|
13558
|
+
);
|
|
13559
|
+
default:
|
|
13560
|
+
throw new LangfuseAPIError({
|
|
13561
|
+
statusCode: _response.error.statusCode,
|
|
13562
|
+
body: _response.error.body,
|
|
13563
|
+
rawResponse: _response.rawResponse
|
|
13564
|
+
});
|
|
13565
|
+
}
|
|
13566
|
+
}
|
|
13567
|
+
switch (_response.error.reason) {
|
|
13568
|
+
case "non-json":
|
|
13569
|
+
throw new LangfuseAPIError({
|
|
13570
|
+
statusCode: _response.error.statusCode,
|
|
13571
|
+
body: _response.error.rawBody,
|
|
13572
|
+
rawResponse: _response.rawResponse
|
|
13573
|
+
});
|
|
13574
|
+
case "timeout":
|
|
13575
|
+
throw new LangfuseAPITimeoutError(
|
|
13576
|
+
"Timeout exceeded when calling PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}."
|
|
13577
|
+
);
|
|
13578
|
+
case "unknown":
|
|
13579
|
+
throw new LangfuseAPIError({
|
|
13580
|
+
message: _response.error.errorMessage,
|
|
13581
|
+
rawResponse: _response.rawResponse
|
|
13582
|
+
});
|
|
13583
|
+
}
|
|
13584
|
+
}
|
|
13585
|
+
/**
|
|
13586
|
+
* Delete an evaluation rule.
|
|
13587
|
+
*
|
|
13588
|
+
* This removes the live-ingestion rule only. It does not delete the referenced evaluator.
|
|
13589
|
+
*
|
|
13590
|
+
* @param {string} evaluationRuleId - Evaluation rule identifier.
|
|
13591
|
+
* @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
|
|
13592
|
+
*
|
|
13593
|
+
* @throws {@link LangfuseAPI.unstable.BadRequestError}
|
|
13594
|
+
* @throws {@link LangfuseAPI.unstable.UnauthorizedError}
|
|
13595
|
+
* @throws {@link LangfuseAPI.unstable.AccessDeniedError}
|
|
13596
|
+
* @throws {@link LangfuseAPI.unstable.NotFoundError}
|
|
13597
|
+
* @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
|
|
13598
|
+
* @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
|
|
13599
|
+
* @throws {@link LangfuseAPI.unstable.InternalServerError}
|
|
13600
|
+
* @throws {@link LangfuseAPI.Error}
|
|
13601
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
13602
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
13603
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
13604
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
13605
|
+
*
|
|
13606
|
+
* @example
|
|
13607
|
+
* await client.unstable.evaluationRules.delete("evaluationRuleId")
|
|
13608
|
+
*/
|
|
13609
|
+
delete(evaluationRuleId, requestOptions) {
|
|
13610
|
+
return HttpResponsePromise.fromPromise(
|
|
13611
|
+
this.__delete(evaluationRuleId, requestOptions)
|
|
13612
|
+
);
|
|
13613
|
+
}
|
|
13614
|
+
async __delete(evaluationRuleId, requestOptions) {
|
|
13615
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
13616
|
+
let _headers = mergeHeaders(
|
|
13617
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
13618
|
+
mergeOnlyDefinedHeaders({
|
|
13619
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
13620
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
13621
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
13622
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
13623
|
+
}),
|
|
13624
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
13625
|
+
);
|
|
13626
|
+
const _response = await fetcher({
|
|
13627
|
+
url: url_exports.join(
|
|
13628
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
13629
|
+
`/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
|
|
13630
|
+
),
|
|
13631
|
+
method: "DELETE",
|
|
13632
|
+
headers: _headers,
|
|
13633
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
13634
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
13635
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
13636
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
13637
|
+
});
|
|
13638
|
+
if (_response.ok) {
|
|
13639
|
+
return {
|
|
13640
|
+
data: _response.body,
|
|
13641
|
+
rawResponse: _response.rawResponse
|
|
13642
|
+
};
|
|
13643
|
+
}
|
|
13644
|
+
if (_response.error.reason === "status-code") {
|
|
13645
|
+
switch (_response.error.statusCode) {
|
|
13646
|
+
case 400:
|
|
13647
|
+
throw new unstable_exports.BadRequestError(
|
|
13648
|
+
_response.error.body,
|
|
13649
|
+
_response.rawResponse
|
|
13650
|
+
);
|
|
13651
|
+
case 401:
|
|
13652
|
+
throw new unstable_exports.UnauthorizedError(
|
|
13653
|
+
_response.error.body,
|
|
13654
|
+
_response.rawResponse
|
|
13655
|
+
);
|
|
13656
|
+
case 403:
|
|
13657
|
+
throw new unstable_exports.AccessDeniedError(
|
|
13658
|
+
_response.error.body,
|
|
13659
|
+
_response.rawResponse
|
|
13660
|
+
);
|
|
13661
|
+
case 404:
|
|
13662
|
+
throw new unstable_exports.NotFoundError(
|
|
13663
|
+
_response.error.body,
|
|
13664
|
+
_response.rawResponse
|
|
13665
|
+
);
|
|
13666
|
+
case 405:
|
|
13667
|
+
throw new unstable_exports.MethodNotAllowedError(
|
|
13668
|
+
_response.error.body,
|
|
13669
|
+
_response.rawResponse
|
|
13670
|
+
);
|
|
13671
|
+
case 429:
|
|
13672
|
+
throw new unstable_exports.TooManyRequestsError(
|
|
13673
|
+
_response.error.body,
|
|
13674
|
+
_response.rawResponse
|
|
13675
|
+
);
|
|
13676
|
+
case 500:
|
|
13677
|
+
throw new unstable_exports.InternalServerError(
|
|
13678
|
+
_response.error.body,
|
|
13679
|
+
_response.rawResponse
|
|
13680
|
+
);
|
|
13681
|
+
case 400:
|
|
13682
|
+
throw new Error2(
|
|
13683
|
+
_response.error.body,
|
|
13684
|
+
_response.rawResponse
|
|
13685
|
+
);
|
|
13686
|
+
case 401:
|
|
13687
|
+
throw new UnauthorizedError(
|
|
13688
|
+
_response.error.body,
|
|
13689
|
+
_response.rawResponse
|
|
13690
|
+
);
|
|
13691
|
+
case 403:
|
|
13692
|
+
throw new AccessDeniedError(
|
|
13693
|
+
_response.error.body,
|
|
13694
|
+
_response.rawResponse
|
|
13695
|
+
);
|
|
13696
|
+
case 405:
|
|
13697
|
+
throw new MethodNotAllowedError(
|
|
13698
|
+
_response.error.body,
|
|
13699
|
+
_response.rawResponse
|
|
13700
|
+
);
|
|
13701
|
+
case 404:
|
|
13702
|
+
throw new NotFoundError(
|
|
13703
|
+
_response.error.body,
|
|
13704
|
+
_response.rawResponse
|
|
13705
|
+
);
|
|
13706
|
+
default:
|
|
13707
|
+
throw new LangfuseAPIError({
|
|
13708
|
+
statusCode: _response.error.statusCode,
|
|
13709
|
+
body: _response.error.body,
|
|
13710
|
+
rawResponse: _response.rawResponse
|
|
13711
|
+
});
|
|
13712
|
+
}
|
|
13713
|
+
}
|
|
13714
|
+
switch (_response.error.reason) {
|
|
13715
|
+
case "non-json":
|
|
13716
|
+
throw new LangfuseAPIError({
|
|
13717
|
+
statusCode: _response.error.statusCode,
|
|
13718
|
+
body: _response.error.rawBody,
|
|
13719
|
+
rawResponse: _response.rawResponse
|
|
13720
|
+
});
|
|
13721
|
+
case "timeout":
|
|
13722
|
+
throw new LangfuseAPITimeoutError(
|
|
13723
|
+
"Timeout exceeded when calling DELETE /api/public/unstable/evaluation-rules/{evaluationRuleId}."
|
|
13724
|
+
);
|
|
13725
|
+
case "unknown":
|
|
13726
|
+
throw new LangfuseAPIError({
|
|
13727
|
+
message: _response.error.errorMessage,
|
|
13728
|
+
rawResponse: _response.rawResponse
|
|
13729
|
+
});
|
|
13730
|
+
}
|
|
13731
|
+
}
|
|
13732
|
+
async _getAuthorizationHeader() {
|
|
13733
|
+
const username = await Supplier.get(this._options.username);
|
|
13734
|
+
const password = await Supplier.get(this._options.password);
|
|
13735
|
+
if (username != null && password != null) {
|
|
13736
|
+
return BasicAuth.toAuthorizationHeader({
|
|
13737
|
+
username,
|
|
13738
|
+
password
|
|
13739
|
+
});
|
|
13740
|
+
}
|
|
13741
|
+
return void 0;
|
|
13742
|
+
}
|
|
13743
|
+
};
|
|
13744
|
+
|
|
13745
|
+
// src/api/api/resources/unstable/resources/evaluators/client/Client.ts
|
|
13746
|
+
var Evaluators = class {
|
|
13747
|
+
constructor(_options) {
|
|
13748
|
+
this._options = _options;
|
|
13749
|
+
}
|
|
13750
|
+
/**
|
|
13751
|
+
* Create an evaluator in the authenticated project.
|
|
13752
|
+
*
|
|
13753
|
+
* Use evaluators to define **how** Langfuse should score data.
|
|
13754
|
+
* LLM-as-a-judge evaluators define a prompt, expected structured output, and optional model configuration.
|
|
13755
|
+
* Code evaluators define source code and a runtime language.
|
|
13756
|
+
*
|
|
13757
|
+
* Naming behavior:
|
|
13758
|
+
* - If this is a new evaluator name in your project, Langfuse creates version `1`.
|
|
13759
|
+
* - If the name already exists in your project, Langfuse creates the next version and returns it.
|
|
13760
|
+
* - When a new project version is created, existing evaluation rules in that project automatically move to the newest version for that evaluator name.
|
|
13761
|
+
*
|
|
13762
|
+
* Recommended workflow:
|
|
13763
|
+
* 1. Create the evaluator.
|
|
13764
|
+
* 2. Read the returned `variables` array.
|
|
13765
|
+
* 3. Read the returned `outputDefinition.dataType` so the client knows whether future scores will be numeric, boolean, or categorical.
|
|
13766
|
+
* 4. Create one or more evaluation rules that reference the returned evaluator family using `name` and `scope`.
|
|
13767
|
+
*
|
|
13768
|
+
* Code evaluator validation:
|
|
13769
|
+
* - At creation, Langfuse only validates the request shape
|
|
13770
|
+
* - 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.
|
|
13771
|
+
*
|
|
13772
|
+
* Recovery guidance:
|
|
13773
|
+
* - `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.
|
|
13774
|
+
* - `400` with `code=invalid_body`: the request shape is malformed. Use the structured `details.issues` array to fix the specific fields and retry.
|
|
13775
|
+
* - `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.
|
|
13776
|
+
* - If `type` is omitted, Langfuse treats the request as `type=llm_as_judge` for backwards compatibility. New clients should send `type` explicitly.
|
|
13777
|
+
*
|
|
13778
|
+
* Unstable API note:
|
|
13779
|
+
* - This surface may evolve while the underlying evaluation data model is being redesigned.
|
|
13780
|
+
*
|
|
13781
|
+
* @param {LangfuseAPI.unstable.CreateEvaluatorRequest} request
|
|
13782
|
+
* @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
|
|
13783
|
+
*
|
|
13784
|
+
* @throws {@link LangfuseAPI.unstable.BadRequestError}
|
|
13785
|
+
* @throws {@link LangfuseAPI.unstable.UnauthorizedError}
|
|
13786
|
+
* @throws {@link LangfuseAPI.unstable.AccessDeniedError}
|
|
13787
|
+
* @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
|
|
13788
|
+
* @throws {@link LangfuseAPI.unstable.ConflictError}
|
|
13789
|
+
* @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
|
|
13790
|
+
* @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
|
|
13791
|
+
* @throws {@link LangfuseAPI.unstable.InternalServerError}
|
|
13792
|
+
* @throws {@link LangfuseAPI.Error}
|
|
13793
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
13794
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
13795
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
13796
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
13797
|
+
*
|
|
13798
|
+
* @example
|
|
13799
|
+
* await client.unstable.evaluators.create({
|
|
13800
|
+
* type: "llm_as_judge",
|
|
13801
|
+
* name: "answer-correctness",
|
|
13802
|
+
* prompt: "You are grading an answer.\n\nInput:\n{{input}}\n\nOutput:\n{{output}}\n\nReturn a score between 0 and 1.\n",
|
|
13803
|
+
* outputDefinition: {
|
|
13804
|
+
* dataType: "NUMERIC",
|
|
13805
|
+
* dataType: "NUMERIC",
|
|
13806
|
+
* reasoning: {
|
|
13807
|
+
* description: "Explain why the score was assigned."
|
|
13808
|
+
* },
|
|
13809
|
+
* score: {
|
|
13810
|
+
* description: "Correctness score between 0 and 1."
|
|
13811
|
+
* }
|
|
13812
|
+
* },
|
|
13813
|
+
* modelConfig: {
|
|
13814
|
+
* provider: "openai",
|
|
13815
|
+
* model: "gpt-4.1-mini"
|
|
13816
|
+
* }
|
|
13817
|
+
* })
|
|
13818
|
+
*
|
|
13819
|
+
* @example
|
|
13820
|
+
* await client.unstable.evaluators.create({
|
|
13821
|
+
* type: "code",
|
|
13822
|
+
* name: "exact-match",
|
|
13823
|
+
* 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",
|
|
13824
|
+
* sourceCodeLanguage: "TYPESCRIPT"
|
|
13825
|
+
* })
|
|
13826
|
+
*
|
|
13827
|
+
* @example
|
|
13828
|
+
* await client.unstable.evaluators.create({
|
|
13829
|
+
* type: "code",
|
|
13830
|
+
* name: "exact-match",
|
|
13831
|
+
* 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",
|
|
13832
|
+
* sourceCodeLanguage: "PYTHON"
|
|
13833
|
+
* })
|
|
13834
|
+
*/
|
|
13835
|
+
create(request, requestOptions) {
|
|
13836
|
+
return HttpResponsePromise.fromPromise(
|
|
13837
|
+
this.__create(request, requestOptions)
|
|
13838
|
+
);
|
|
13839
|
+
}
|
|
13840
|
+
async __create(request, requestOptions) {
|
|
13841
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
13842
|
+
let _headers = mergeHeaders(
|
|
13843
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
13844
|
+
mergeOnlyDefinedHeaders({
|
|
13845
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
13846
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
13847
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
13848
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
13849
|
+
}),
|
|
13850
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
13851
|
+
);
|
|
13852
|
+
const _response = await fetcher({
|
|
13853
|
+
url: url_exports.join(
|
|
13854
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
13855
|
+
"/api/public/unstable/evaluators"
|
|
13856
|
+
),
|
|
13857
|
+
method: "POST",
|
|
13858
|
+
headers: _headers,
|
|
13859
|
+
contentType: "application/json",
|
|
13860
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
13861
|
+
requestType: "json",
|
|
13862
|
+
body: request,
|
|
13863
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
13864
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
13865
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
13866
|
+
});
|
|
13867
|
+
if (_response.ok) {
|
|
13868
|
+
return {
|
|
13869
|
+
data: _response.body,
|
|
13870
|
+
rawResponse: _response.rawResponse
|
|
13871
|
+
};
|
|
13872
|
+
}
|
|
13873
|
+
if (_response.error.reason === "status-code") {
|
|
13874
|
+
switch (_response.error.statusCode) {
|
|
13875
|
+
case 400:
|
|
13876
|
+
throw new unstable_exports.BadRequestError(
|
|
13877
|
+
_response.error.body,
|
|
13878
|
+
_response.rawResponse
|
|
13879
|
+
);
|
|
13880
|
+
case 401:
|
|
13881
|
+
throw new unstable_exports.UnauthorizedError(
|
|
13882
|
+
_response.error.body,
|
|
13883
|
+
_response.rawResponse
|
|
13884
|
+
);
|
|
13885
|
+
case 403:
|
|
13886
|
+
throw new unstable_exports.AccessDeniedError(
|
|
13887
|
+
_response.error.body,
|
|
13888
|
+
_response.rawResponse
|
|
13889
|
+
);
|
|
13890
|
+
case 405:
|
|
13891
|
+
throw new unstable_exports.MethodNotAllowedError(
|
|
13892
|
+
_response.error.body,
|
|
13893
|
+
_response.rawResponse
|
|
13894
|
+
);
|
|
13895
|
+
case 409:
|
|
13896
|
+
throw new unstable_exports.ConflictError(
|
|
13897
|
+
_response.error.body,
|
|
13898
|
+
_response.rawResponse
|
|
13899
|
+
);
|
|
13900
|
+
case 422:
|
|
13901
|
+
throw new unstable_exports.UnprocessableContentError(
|
|
13902
|
+
_response.error.body,
|
|
13903
|
+
_response.rawResponse
|
|
13904
|
+
);
|
|
13905
|
+
case 429:
|
|
13906
|
+
throw new unstable_exports.TooManyRequestsError(
|
|
13907
|
+
_response.error.body,
|
|
13908
|
+
_response.rawResponse
|
|
13909
|
+
);
|
|
13910
|
+
case 500:
|
|
13911
|
+
throw new unstable_exports.InternalServerError(
|
|
13912
|
+
_response.error.body,
|
|
13913
|
+
_response.rawResponse
|
|
13914
|
+
);
|
|
13915
|
+
case 400:
|
|
13916
|
+
throw new Error2(
|
|
13917
|
+
_response.error.body,
|
|
13918
|
+
_response.rawResponse
|
|
13919
|
+
);
|
|
13920
|
+
case 401:
|
|
13921
|
+
throw new UnauthorizedError(
|
|
13922
|
+
_response.error.body,
|
|
13923
|
+
_response.rawResponse
|
|
13924
|
+
);
|
|
13925
|
+
case 403:
|
|
13926
|
+
throw new AccessDeniedError(
|
|
13927
|
+
_response.error.body,
|
|
13928
|
+
_response.rawResponse
|
|
13929
|
+
);
|
|
13930
|
+
case 405:
|
|
13931
|
+
throw new MethodNotAllowedError(
|
|
13932
|
+
_response.error.body,
|
|
13933
|
+
_response.rawResponse
|
|
13934
|
+
);
|
|
13935
|
+
case 404:
|
|
13936
|
+
throw new NotFoundError(
|
|
13937
|
+
_response.error.body,
|
|
13938
|
+
_response.rawResponse
|
|
13939
|
+
);
|
|
13940
|
+
default:
|
|
13941
|
+
throw new LangfuseAPIError({
|
|
13942
|
+
statusCode: _response.error.statusCode,
|
|
13943
|
+
body: _response.error.body,
|
|
13944
|
+
rawResponse: _response.rawResponse
|
|
13945
|
+
});
|
|
13946
|
+
}
|
|
13947
|
+
}
|
|
13948
|
+
switch (_response.error.reason) {
|
|
13949
|
+
case "non-json":
|
|
13950
|
+
throw new LangfuseAPIError({
|
|
13951
|
+
statusCode: _response.error.statusCode,
|
|
13952
|
+
body: _response.error.rawBody,
|
|
13953
|
+
rawResponse: _response.rawResponse
|
|
13954
|
+
});
|
|
13955
|
+
case "timeout":
|
|
13956
|
+
throw new LangfuseAPITimeoutError(
|
|
13957
|
+
"Timeout exceeded when calling POST /api/public/unstable/evaluators."
|
|
13958
|
+
);
|
|
13959
|
+
case "unknown":
|
|
13960
|
+
throw new LangfuseAPIError({
|
|
13961
|
+
message: _response.error.errorMessage,
|
|
13962
|
+
rawResponse: _response.rawResponse
|
|
13963
|
+
});
|
|
13964
|
+
}
|
|
13965
|
+
}
|
|
13966
|
+
/**
|
|
13967
|
+
* List the evaluators available to the authenticated project.
|
|
13968
|
+
*
|
|
13969
|
+
* Important behavior:
|
|
13970
|
+
* - This endpoint returns the latest version of each available evaluator.
|
|
13971
|
+
* - Results can include evaluators from your project and Langfuse-managed evaluators.
|
|
13972
|
+
* - If the same evaluator name exists in both places, both are returned as separate items with different `scope` values.
|
|
13973
|
+
*
|
|
13974
|
+
* @param {LangfuseAPI.unstable.ListEvaluatorsRequest} request
|
|
13975
|
+
* @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
|
|
13976
|
+
*
|
|
13977
|
+
* @throws {@link LangfuseAPI.unstable.BadRequestError}
|
|
13978
|
+
* @throws {@link LangfuseAPI.unstable.UnauthorizedError}
|
|
13979
|
+
* @throws {@link LangfuseAPI.unstable.AccessDeniedError}
|
|
13980
|
+
* @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
|
|
13981
|
+
* @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
|
|
13982
|
+
* @throws {@link LangfuseAPI.unstable.InternalServerError}
|
|
13983
|
+
* @throws {@link LangfuseAPI.Error}
|
|
13984
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
13985
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
13986
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
13987
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
13988
|
+
*
|
|
13989
|
+
* @example
|
|
13990
|
+
* await client.unstable.evaluators.list()
|
|
13991
|
+
*/
|
|
13992
|
+
list(request = {}, requestOptions) {
|
|
13993
|
+
return HttpResponsePromise.fromPromise(
|
|
13994
|
+
this.__list(request, requestOptions)
|
|
13995
|
+
);
|
|
13996
|
+
}
|
|
13997
|
+
async __list(request = {}, requestOptions) {
|
|
13998
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
13999
|
+
const { page, limit } = request;
|
|
14000
|
+
const _queryParams = {};
|
|
14001
|
+
if (page != null) {
|
|
14002
|
+
_queryParams["page"] = page.toString();
|
|
14003
|
+
}
|
|
14004
|
+
if (limit != null) {
|
|
14005
|
+
_queryParams["limit"] = limit.toString();
|
|
14006
|
+
}
|
|
14007
|
+
let _headers = mergeHeaders(
|
|
14008
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
14009
|
+
mergeOnlyDefinedHeaders({
|
|
14010
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
14011
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
14012
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
14013
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
14014
|
+
}),
|
|
14015
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
14016
|
+
);
|
|
14017
|
+
const _response = await fetcher({
|
|
14018
|
+
url: url_exports.join(
|
|
14019
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
14020
|
+
"/api/public/unstable/evaluators"
|
|
14021
|
+
),
|
|
14022
|
+
method: "GET",
|
|
14023
|
+
headers: _headers,
|
|
14024
|
+
queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
|
|
14025
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
14026
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
14027
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
14028
|
+
});
|
|
14029
|
+
if (_response.ok) {
|
|
14030
|
+
return {
|
|
14031
|
+
data: _response.body,
|
|
14032
|
+
rawResponse: _response.rawResponse
|
|
14033
|
+
};
|
|
14034
|
+
}
|
|
14035
|
+
if (_response.error.reason === "status-code") {
|
|
14036
|
+
switch (_response.error.statusCode) {
|
|
14037
|
+
case 400:
|
|
14038
|
+
throw new unstable_exports.BadRequestError(
|
|
14039
|
+
_response.error.body,
|
|
14040
|
+
_response.rawResponse
|
|
14041
|
+
);
|
|
14042
|
+
case 401:
|
|
14043
|
+
throw new unstable_exports.UnauthorizedError(
|
|
14044
|
+
_response.error.body,
|
|
14045
|
+
_response.rawResponse
|
|
14046
|
+
);
|
|
14047
|
+
case 403:
|
|
14048
|
+
throw new unstable_exports.AccessDeniedError(
|
|
14049
|
+
_response.error.body,
|
|
14050
|
+
_response.rawResponse
|
|
14051
|
+
);
|
|
14052
|
+
case 405:
|
|
14053
|
+
throw new unstable_exports.MethodNotAllowedError(
|
|
14054
|
+
_response.error.body,
|
|
14055
|
+
_response.rawResponse
|
|
14056
|
+
);
|
|
14057
|
+
case 429:
|
|
14058
|
+
throw new unstable_exports.TooManyRequestsError(
|
|
14059
|
+
_response.error.body,
|
|
14060
|
+
_response.rawResponse
|
|
14061
|
+
);
|
|
14062
|
+
case 500:
|
|
14063
|
+
throw new unstable_exports.InternalServerError(
|
|
14064
|
+
_response.error.body,
|
|
14065
|
+
_response.rawResponse
|
|
14066
|
+
);
|
|
14067
|
+
case 400:
|
|
14068
|
+
throw new Error2(
|
|
14069
|
+
_response.error.body,
|
|
14070
|
+
_response.rawResponse
|
|
14071
|
+
);
|
|
14072
|
+
case 401:
|
|
14073
|
+
throw new UnauthorizedError(
|
|
14074
|
+
_response.error.body,
|
|
14075
|
+
_response.rawResponse
|
|
14076
|
+
);
|
|
14077
|
+
case 403:
|
|
14078
|
+
throw new AccessDeniedError(
|
|
14079
|
+
_response.error.body,
|
|
14080
|
+
_response.rawResponse
|
|
14081
|
+
);
|
|
14082
|
+
case 405:
|
|
14083
|
+
throw new MethodNotAllowedError(
|
|
14084
|
+
_response.error.body,
|
|
14085
|
+
_response.rawResponse
|
|
14086
|
+
);
|
|
14087
|
+
case 404:
|
|
14088
|
+
throw new NotFoundError(
|
|
14089
|
+
_response.error.body,
|
|
14090
|
+
_response.rawResponse
|
|
14091
|
+
);
|
|
14092
|
+
default:
|
|
14093
|
+
throw new LangfuseAPIError({
|
|
14094
|
+
statusCode: _response.error.statusCode,
|
|
14095
|
+
body: _response.error.body,
|
|
14096
|
+
rawResponse: _response.rawResponse
|
|
14097
|
+
});
|
|
14098
|
+
}
|
|
14099
|
+
}
|
|
14100
|
+
switch (_response.error.reason) {
|
|
14101
|
+
case "non-json":
|
|
14102
|
+
throw new LangfuseAPIError({
|
|
14103
|
+
statusCode: _response.error.statusCode,
|
|
14104
|
+
body: _response.error.rawBody,
|
|
14105
|
+
rawResponse: _response.rawResponse
|
|
14106
|
+
});
|
|
14107
|
+
case "timeout":
|
|
14108
|
+
throw new LangfuseAPITimeoutError(
|
|
14109
|
+
"Timeout exceeded when calling GET /api/public/unstable/evaluators."
|
|
14110
|
+
);
|
|
14111
|
+
case "unknown":
|
|
14112
|
+
throw new LangfuseAPIError({
|
|
14113
|
+
message: _response.error.errorMessage,
|
|
14114
|
+
rawResponse: _response.rawResponse
|
|
14115
|
+
});
|
|
14116
|
+
}
|
|
14117
|
+
}
|
|
14118
|
+
/**
|
|
14119
|
+
* Get one evaluator by `id`.
|
|
14120
|
+
*
|
|
14121
|
+
* 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.
|
|
14122
|
+
*
|
|
14123
|
+
* @param {string} evaluatorId - Evaluator identifier returned by the evaluator endpoints.
|
|
14124
|
+
* @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
|
|
14125
|
+
*
|
|
14126
|
+
* @throws {@link LangfuseAPI.unstable.BadRequestError}
|
|
14127
|
+
* @throws {@link LangfuseAPI.unstable.UnauthorizedError}
|
|
14128
|
+
* @throws {@link LangfuseAPI.unstable.AccessDeniedError}
|
|
14129
|
+
* @throws {@link LangfuseAPI.unstable.NotFoundError}
|
|
14130
|
+
* @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
|
|
14131
|
+
* @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
|
|
14132
|
+
* @throws {@link LangfuseAPI.unstable.InternalServerError}
|
|
14133
|
+
* @throws {@link LangfuseAPI.Error}
|
|
14134
|
+
* @throws {@link LangfuseAPI.UnauthorizedError}
|
|
14135
|
+
* @throws {@link LangfuseAPI.AccessDeniedError}
|
|
14136
|
+
* @throws {@link LangfuseAPI.MethodNotAllowedError}
|
|
14137
|
+
* @throws {@link LangfuseAPI.NotFoundError}
|
|
14138
|
+
*
|
|
14139
|
+
* @example
|
|
14140
|
+
* await client.unstable.evaluators.get("evaluatorId")
|
|
14141
|
+
*/
|
|
14142
|
+
get(evaluatorId, requestOptions) {
|
|
14143
|
+
return HttpResponsePromise.fromPromise(
|
|
14144
|
+
this.__get(evaluatorId, requestOptions)
|
|
14145
|
+
);
|
|
14146
|
+
}
|
|
14147
|
+
async __get(evaluatorId, requestOptions) {
|
|
14148
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
14149
|
+
let _headers = mergeHeaders(
|
|
14150
|
+
(_a2 = this._options) == null ? void 0 : _a2.headers,
|
|
14151
|
+
mergeOnlyDefinedHeaders({
|
|
14152
|
+
Authorization: await this._getAuthorizationHeader(),
|
|
14153
|
+
"X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
|
|
14154
|
+
"X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
|
|
14155
|
+
"X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
|
|
14156
|
+
}),
|
|
14157
|
+
requestOptions == null ? void 0 : requestOptions.headers
|
|
14158
|
+
);
|
|
14159
|
+
const _response = await fetcher({
|
|
14160
|
+
url: url_exports.join(
|
|
14161
|
+
(_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
|
|
14162
|
+
`/api/public/unstable/evaluators/${encodeURIComponent(evaluatorId)}`
|
|
14163
|
+
),
|
|
14164
|
+
method: "GET",
|
|
14165
|
+
headers: _headers,
|
|
14166
|
+
queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
|
|
14167
|
+
timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
|
|
14168
|
+
maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
|
|
14169
|
+
abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
|
|
14170
|
+
});
|
|
14171
|
+
if (_response.ok) {
|
|
14172
|
+
return {
|
|
14173
|
+
data: _response.body,
|
|
14174
|
+
rawResponse: _response.rawResponse
|
|
14175
|
+
};
|
|
14176
|
+
}
|
|
14177
|
+
if (_response.error.reason === "status-code") {
|
|
14178
|
+
switch (_response.error.statusCode) {
|
|
14179
|
+
case 400:
|
|
14180
|
+
throw new unstable_exports.BadRequestError(
|
|
14181
|
+
_response.error.body,
|
|
14182
|
+
_response.rawResponse
|
|
14183
|
+
);
|
|
14184
|
+
case 401:
|
|
14185
|
+
throw new unstable_exports.UnauthorizedError(
|
|
14186
|
+
_response.error.body,
|
|
14187
|
+
_response.rawResponse
|
|
14188
|
+
);
|
|
14189
|
+
case 403:
|
|
14190
|
+
throw new unstable_exports.AccessDeniedError(
|
|
14191
|
+
_response.error.body,
|
|
14192
|
+
_response.rawResponse
|
|
14193
|
+
);
|
|
14194
|
+
case 404:
|
|
14195
|
+
throw new unstable_exports.NotFoundError(
|
|
14196
|
+
_response.error.body,
|
|
14197
|
+
_response.rawResponse
|
|
14198
|
+
);
|
|
14199
|
+
case 405:
|
|
14200
|
+
throw new unstable_exports.MethodNotAllowedError(
|
|
14201
|
+
_response.error.body,
|
|
14202
|
+
_response.rawResponse
|
|
14203
|
+
);
|
|
14204
|
+
case 429:
|
|
14205
|
+
throw new unstable_exports.TooManyRequestsError(
|
|
14206
|
+
_response.error.body,
|
|
14207
|
+
_response.rawResponse
|
|
14208
|
+
);
|
|
14209
|
+
case 500:
|
|
14210
|
+
throw new unstable_exports.InternalServerError(
|
|
14211
|
+
_response.error.body,
|
|
14212
|
+
_response.rawResponse
|
|
14213
|
+
);
|
|
14214
|
+
case 400:
|
|
14215
|
+
throw new Error2(
|
|
14216
|
+
_response.error.body,
|
|
14217
|
+
_response.rawResponse
|
|
14218
|
+
);
|
|
14219
|
+
case 401:
|
|
14220
|
+
throw new UnauthorizedError(
|
|
14221
|
+
_response.error.body,
|
|
14222
|
+
_response.rawResponse
|
|
14223
|
+
);
|
|
14224
|
+
case 403:
|
|
14225
|
+
throw new AccessDeniedError(
|
|
14226
|
+
_response.error.body,
|
|
14227
|
+
_response.rawResponse
|
|
14228
|
+
);
|
|
14229
|
+
case 405:
|
|
14230
|
+
throw new MethodNotAllowedError(
|
|
14231
|
+
_response.error.body,
|
|
14232
|
+
_response.rawResponse
|
|
14233
|
+
);
|
|
14234
|
+
case 404:
|
|
14235
|
+
throw new NotFoundError(
|
|
14236
|
+
_response.error.body,
|
|
14237
|
+
_response.rawResponse
|
|
14238
|
+
);
|
|
14239
|
+
default:
|
|
14240
|
+
throw new LangfuseAPIError({
|
|
14241
|
+
statusCode: _response.error.statusCode,
|
|
14242
|
+
body: _response.error.body,
|
|
14243
|
+
rawResponse: _response.rawResponse
|
|
14244
|
+
});
|
|
14245
|
+
}
|
|
14246
|
+
}
|
|
14247
|
+
switch (_response.error.reason) {
|
|
14248
|
+
case "non-json":
|
|
14249
|
+
throw new LangfuseAPIError({
|
|
14250
|
+
statusCode: _response.error.statusCode,
|
|
14251
|
+
body: _response.error.rawBody,
|
|
14252
|
+
rawResponse: _response.rawResponse
|
|
14253
|
+
});
|
|
14254
|
+
case "timeout":
|
|
14255
|
+
throw new LangfuseAPITimeoutError(
|
|
14256
|
+
"Timeout exceeded when calling GET /api/public/unstable/evaluators/{evaluatorId}."
|
|
14257
|
+
);
|
|
14258
|
+
case "unknown":
|
|
14259
|
+
throw new LangfuseAPIError({
|
|
14260
|
+
message: _response.error.errorMessage,
|
|
14261
|
+
rawResponse: _response.rawResponse
|
|
14262
|
+
});
|
|
14263
|
+
}
|
|
14264
|
+
}
|
|
14265
|
+
async _getAuthorizationHeader() {
|
|
14266
|
+
const username = await Supplier.get(this._options.username);
|
|
14267
|
+
const password = await Supplier.get(this._options.password);
|
|
14268
|
+
if (username != null && password != null) {
|
|
14269
|
+
return BasicAuth.toAuthorizationHeader({
|
|
14270
|
+
username,
|
|
14271
|
+
password
|
|
14272
|
+
});
|
|
14273
|
+
}
|
|
14274
|
+
return void 0;
|
|
14275
|
+
}
|
|
14276
|
+
};
|
|
14277
|
+
|
|
14278
|
+
// src/api/api/resources/unstable/client/Client.ts
|
|
14279
|
+
var Unstable = class {
|
|
14280
|
+
constructor(_options) {
|
|
14281
|
+
this._options = _options;
|
|
14282
|
+
}
|
|
14283
|
+
get evaluationRules() {
|
|
14284
|
+
var _a2;
|
|
14285
|
+
return (_a2 = this._evaluationRules) != null ? _a2 : this._evaluationRules = new EvaluationRules(this._options);
|
|
14286
|
+
}
|
|
14287
|
+
get evaluators() {
|
|
14288
|
+
var _a2;
|
|
14289
|
+
return (_a2 = this._evaluators) != null ? _a2 : this._evaluators = new Evaluators(this._options);
|
|
14290
|
+
}
|
|
14291
|
+
};
|
|
14292
|
+
|
|
14293
|
+
// src/api/Client.ts
|
|
14294
|
+
var LangfuseAPIClient = class {
|
|
14295
|
+
constructor(_options) {
|
|
14296
|
+
this._options = {
|
|
14297
|
+
..._options,
|
|
14298
|
+
headers: mergeHeaders(
|
|
14299
|
+
{
|
|
14300
|
+
"X-Langfuse-Sdk-Name": _options == null ? void 0 : _options.xLangfuseSdkName,
|
|
14301
|
+
"X-Langfuse-Sdk-Version": _options == null ? void 0 : _options.xLangfuseSdkVersion,
|
|
14302
|
+
"X-Langfuse-Public-Key": _options == null ? void 0 : _options.xLangfusePublicKey
|
|
14303
|
+
},
|
|
14304
|
+
_options == null ? void 0 : _options.headers
|
|
14305
|
+
)
|
|
14306
|
+
};
|
|
14307
|
+
}
|
|
14308
|
+
get annotationQueues() {
|
|
14309
|
+
var _a2;
|
|
14310
|
+
return (_a2 = this._annotationQueues) != null ? _a2 : this._annotationQueues = new AnnotationQueues(this._options);
|
|
14311
|
+
}
|
|
14312
|
+
get blobStorageIntegrations() {
|
|
14313
|
+
var _a2;
|
|
14314
|
+
return (_a2 = this._blobStorageIntegrations) != null ? _a2 : this._blobStorageIntegrations = new BlobStorageIntegrations(
|
|
14315
|
+
this._options
|
|
14316
|
+
);
|
|
14317
|
+
}
|
|
14318
|
+
get comments() {
|
|
14319
|
+
var _a2;
|
|
14320
|
+
return (_a2 = this._comments) != null ? _a2 : this._comments = new Comments(this._options);
|
|
14321
|
+
}
|
|
14322
|
+
get datasetItems() {
|
|
14323
|
+
var _a2;
|
|
14324
|
+
return (_a2 = this._datasetItems) != null ? _a2 : this._datasetItems = new DatasetItems(this._options);
|
|
14325
|
+
}
|
|
14326
|
+
get datasetRunItems() {
|
|
14327
|
+
var _a2;
|
|
12201
14328
|
return (_a2 = this._datasetRunItems) != null ? _a2 : this._datasetRunItems = new DatasetRunItems(this._options);
|
|
12202
14329
|
}
|
|
12203
14330
|
get datasets() {
|
|
@@ -12264,6 +14391,10 @@ var LangfuseAPIClient = class {
|
|
|
12264
14391
|
var _a2;
|
|
12265
14392
|
return (_a2 = this._scoreConfigs) != null ? _a2 : this._scoreConfigs = new ScoreConfigs(this._options);
|
|
12266
14393
|
}
|
|
14394
|
+
get scoresV3() {
|
|
14395
|
+
var _a2;
|
|
14396
|
+
return (_a2 = this._scoresV3) != null ? _a2 : this._scoresV3 = new ScoresV3(this._options);
|
|
14397
|
+
}
|
|
12267
14398
|
get scores() {
|
|
12268
14399
|
var _a2;
|
|
12269
14400
|
return (_a2 = this._scores) != null ? _a2 : this._scores = new Scores(this._options);
|
|
@@ -12276,6 +14407,10 @@ var LangfuseAPIClient = class {
|
|
|
12276
14407
|
var _a2;
|
|
12277
14408
|
return (_a2 = this._trace) != null ? _a2 : this._trace = new Trace(this._options);
|
|
12278
14409
|
}
|
|
14410
|
+
get unstable() {
|
|
14411
|
+
var _a2;
|
|
14412
|
+
return (_a2 = this._unstable) != null ? _a2 : this._unstable = new Unstable(this._options);
|
|
14413
|
+
}
|
|
12279
14414
|
};
|
|
12280
14415
|
|
|
12281
14416
|
// src/media.ts
|
|
@@ -12859,8 +14994,10 @@ function getSpanKeyFromBaggageKey(baggageKey) {
|
|
|
12859
14994
|
AccessDeniedError,
|
|
12860
14995
|
AnnotationQueueObjectType,
|
|
12861
14996
|
AnnotationQueueStatus,
|
|
14997
|
+
BlobStorageExportFieldGroup,
|
|
12862
14998
|
BlobStorageExportFrequency,
|
|
12863
14999
|
BlobStorageExportMode,
|
|
15000
|
+
BlobStorageExportSource,
|
|
12864
15001
|
BlobStorageIntegrationFileType,
|
|
12865
15002
|
BlobStorageIntegrationType,
|
|
12866
15003
|
BlobStorageSyncStatus,
|
|
@@ -12939,10 +15076,12 @@ function getSpanKeyFromBaggageKey(baggageKey) {
|
|
|
12939
15076
|
scim,
|
|
12940
15077
|
scoreConfigs,
|
|
12941
15078
|
scores,
|
|
15079
|
+
scoresV3,
|
|
12942
15080
|
serializeValue,
|
|
12943
15081
|
sessions,
|
|
12944
15082
|
setLangfuseTraceIdInBaggage,
|
|
12945
15083
|
trace,
|
|
15084
|
+
unstable,
|
|
12946
15085
|
utils
|
|
12947
15086
|
});
|
|
12948
15087
|
//# sourceMappingURL=index.cjs.map
|