@langfuse/core 5.11.0 → 5.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -276,7 +276,7 @@ var resetGlobalLogger = () => {
276
276
  // package.json
277
277
  var package_default = {
278
278
  name: "@langfuse/core",
279
- version: "5.11.0",
279
+ version: "5.11.1",
280
280
  description: "Core functions and utilities for Langfuse packages",
281
281
  type: "module",
282
282
  sideEffects: false,
@@ -951,9 +951,17 @@ var evaluationRules_exports = {};
951
951
  // src/api/api/resources/evaluators/index.ts
952
952
  var evaluators_exports = {};
953
953
  __export(evaluators_exports, {
954
+ EvaluatorChatMessageRole: () => EvaluatorChatMessageRole,
954
955
  EvaluatorStatus: () => EvaluatorStatus
955
956
  });
956
957
 
958
+ // src/api/api/resources/evaluators/types/EvaluatorChatMessageRole.ts
959
+ var EvaluatorChatMessageRole = {
960
+ System: "system",
961
+ User: "user",
962
+ Assistant: "assistant"
963
+ };
964
+
957
965
  // src/api/api/resources/evaluators/types/EvaluatorStatus.ts
958
966
  var EvaluatorStatus = {
959
967
  Active: "active",
@@ -1235,145 +1243,23 @@ var unstable_exports = {};
1235
1243
  __export(unstable_exports, {
1236
1244
  AccessDeniedError: () => AccessDeniedError2,
1237
1245
  BadRequestError: () => BadRequestError2,
1238
- CodeEvaluatorSourceCodeLanguage: () => CodeEvaluatorSourceCodeLanguage2,
1239
1246
  ConflictError: () => ConflictError2,
1240
1247
  DashboardWidgetChartType: () => DashboardWidgetChartType,
1241
1248
  DashboardWidgetMetricAggregation: () => DashboardWidgetMetricAggregation,
1242
1249
  DashboardWidgetSortOrder: () => DashboardWidgetSortOrder,
1243
1250
  DashboardWidgetView: () => DashboardWidgetView,
1244
1251
  DashboardWidgetViewWithLegacy: () => DashboardWidgetViewWithLegacy,
1245
- EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator2,
1246
- EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator2,
1247
- EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator2,
1248
- EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator2,
1249
- EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator2,
1250
- EvaluationRuleStatus: () => EvaluationRuleStatus,
1251
- EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator2,
1252
- EvaluationRuleTarget: () => EvaluationRuleTarget,
1253
- EvaluationRuleTimeScope: () => EvaluationRuleTimeScope,
1254
- EvaluatorOutputDataType: () => EvaluatorOutputDataType,
1255
- EvaluatorType: () => EvaluatorType2,
1256
1252
  InternalServerError: () => InternalServerError2,
1257
- LegacyEvaluationObject: () => LegacyEvaluationObject2,
1258
- LegacyEvaluationRuleTarget: () => LegacyEvaluationRuleTarget,
1259
- LlmAsJudgeEvaluatorType: () => LlmAsJudgeEvaluatorType,
1260
1253
  MethodNotAllowedError: () => MethodNotAllowedError2,
1261
1254
  NotFoundError: () => NotFoundError2,
1262
- PromptVariableMappingSource: () => PromptVariableMappingSource2,
1263
1255
  PublicApiErrorCode: () => PublicApiErrorCode2,
1264
1256
  TooManyRequestsError: () => TooManyRequestsError2,
1265
1257
  UnauthorizedError: () => UnauthorizedError2,
1266
- UnprocessableContentError: () => UnprocessableContentError,
1267
- commons: () => commons_exports2,
1268
1258
  dashboardWidgets: () => dashboardWidgets_exports,
1269
1259
  dashboards: () => dashboards_exports,
1270
- errors: () => errors_exports2,
1271
- evaluationRules: () => evaluationRules_exports2,
1272
- evaluators: () => evaluators_exports2
1273
- });
1274
-
1275
- // src/api/api/resources/unstable/resources/commons/index.ts
1276
- var commons_exports2 = {};
1277
- __export(commons_exports2, {
1278
- CodeEvaluatorSourceCodeLanguage: () => CodeEvaluatorSourceCodeLanguage2,
1279
- EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator2,
1280
- EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator2,
1281
- EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator2,
1282
- EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator2,
1283
- EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator2,
1284
- EvaluationRuleStatus: () => EvaluationRuleStatus,
1285
- EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator2,
1286
- EvaluationRuleTarget: () => EvaluationRuleTarget,
1287
- EvaluatorOutputDataType: () => EvaluatorOutputDataType,
1288
- EvaluatorType: () => EvaluatorType2,
1289
- PromptVariableMappingSource: () => PromptVariableMappingSource2
1260
+ errors: () => errors_exports2
1290
1261
  });
1291
1262
 
1292
- // src/api/api/resources/unstable/resources/commons/types/EvaluatorType.ts
1293
- var EvaluatorType2 = {
1294
- LlmAsJudge: "llm_as_judge",
1295
- Code: "code"
1296
- };
1297
-
1298
- // src/api/api/resources/unstable/resources/commons/types/CodeEvaluatorSourceCodeLanguage.ts
1299
- var CodeEvaluatorSourceCodeLanguage2 = {
1300
- Python: "PYTHON",
1301
- Typescript: "TYPESCRIPT"
1302
- };
1303
-
1304
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleTarget.ts
1305
- var EvaluationRuleTarget = {
1306
- Observation: "observation",
1307
- Experiment: "experiment"
1308
- };
1309
-
1310
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStatus.ts
1311
- var EvaluationRuleStatus = {
1312
- Active: "active",
1313
- Inactive: "inactive",
1314
- Paused: "paused"
1315
- };
1316
-
1317
- // src/api/api/resources/unstable/resources/commons/types/PromptVariableMappingSource.ts
1318
- var PromptVariableMappingSource2 = {
1319
- Input: "input",
1320
- Output: "output",
1321
- Metadata: "metadata",
1322
- ToolCalls: "tool_calls",
1323
- ExpectedOutput: "expected_output",
1324
- ExperimentItemMetadata: "experiment_item_metadata"
1325
- };
1326
-
1327
- // src/api/api/resources/unstable/resources/commons/types/EvaluatorOutputDataType.ts
1328
- var EvaluatorOutputDataType = {
1329
- Numeric: "NUMERIC",
1330
- Boolean: "BOOLEAN",
1331
- Categorical: "CATEGORICAL"
1332
- };
1333
-
1334
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStringFilterOperator.ts
1335
- var EvaluationRuleStringFilterOperator2 = {
1336
- Equals: "=",
1337
- Contains: "contains",
1338
- DoesNotContain: "does not contain",
1339
- StartsWith: "starts with",
1340
- EndsWith: "ends with"
1341
- };
1342
-
1343
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNumberFilterOperator.ts
1344
- var EvaluationRuleNumberFilterOperator2 = {
1345
- Equals: "=",
1346
- GreaterThan: ">",
1347
- LessThan: "<",
1348
- GreaterThanOrEqual: ">=",
1349
- LessThanOrEqual: "<="
1350
- };
1351
-
1352
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleOptionsFilterOperator.ts
1353
- var EvaluationRuleOptionsFilterOperator2 = {
1354
- AnyOf: "any of",
1355
- NoneOf: "none of"
1356
- };
1357
-
1358
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleArrayOptionsFilterOperator.ts
1359
- var EvaluationRuleArrayOptionsFilterOperator2 = {
1360
- AnyOf: "any of",
1361
- NoneOf: "none of",
1362
- AllOf: "all of"
1363
- };
1364
-
1365
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleBooleanFilterOperator.ts
1366
- var EvaluationRuleBooleanFilterOperator2 = {
1367
- Equals: "=",
1368
- NotEquals: "<>"
1369
- };
1370
-
1371
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNullFilterOperator.ts
1372
- var EvaluationRuleNullFilterOperator2 = {
1373
- IsNull: "is null",
1374
- IsNotNull: "is not null"
1375
- };
1376
-
1377
1263
  // src/api/api/resources/unstable/resources/dashboardWidgets/index.ts
1378
1264
  var dashboardWidgets_exports = {};
1379
1265
  __export(dashboardWidgets_exports, {
@@ -1450,8 +1336,7 @@ __export(errors_exports2, {
1450
1336
  NotFoundError: () => NotFoundError2,
1451
1337
  PublicApiErrorCode: () => PublicApiErrorCode2,
1452
1338
  TooManyRequestsError: () => TooManyRequestsError2,
1453
- UnauthorizedError: () => UnauthorizedError2,
1454
- UnprocessableContentError: () => UnprocessableContentError
1339
+ UnauthorizedError: () => UnauthorizedError2
1455
1340
  });
1456
1341
 
1457
1342
  // src/api/api/resources/unstable/resources/errors/types/PublicApiErrorCode.ts
@@ -1461,16 +1346,8 @@ var PublicApiErrorCode2 = {
1461
1346
  InvalidRequest: "invalid_request",
1462
1347
  InvalidQuery: "invalid_query",
1463
1348
  InvalidBody: "invalid_body",
1464
- InvalidFilterValue: "invalid_filter_value",
1465
- InvalidJsonPath: "invalid_json_path",
1466
- InvalidVariableMapping: "invalid_variable_mapping",
1467
- MissingVariableMapping: "missing_variable_mapping",
1468
- DuplicateVariableMapping: "duplicate_variable_mapping",
1469
1349
  ResourceNotFound: "resource_not_found",
1470
- NameConflict: "name_conflict",
1471
- EvaluatorPreflightFailed: "evaluator_preflight_failed",
1472
1350
  Conflict: "conflict",
1473
- UnprocessableContent: "unprocessable_content",
1474
1351
  RateLimited: "rate_limited",
1475
1352
  MethodNotAllowed: "method_not_allowed",
1476
1353
  InternalError: "internal_error"
@@ -1554,19 +1431,6 @@ var ConflictError2 = class _ConflictError extends LangfuseAPIError {
1554
1431
  }
1555
1432
  };
1556
1433
 
1557
- // src/api/api/resources/unstable/resources/errors/errors/UnprocessableContentError.ts
1558
- var UnprocessableContentError = class _UnprocessableContentError extends LangfuseAPIError {
1559
- constructor(body, rawResponse) {
1560
- super({
1561
- message: "UnprocessableContentError",
1562
- statusCode: 422,
1563
- body,
1564
- rawResponse
1565
- });
1566
- Object.setPrototypeOf(this, _UnprocessableContentError.prototype);
1567
- }
1568
- };
1569
-
1570
1434
  // src/api/api/resources/unstable/resources/errors/errors/TooManyRequestsError.ts
1571
1435
  var TooManyRequestsError2 = class _TooManyRequestsError extends LangfuseAPIError {
1572
1436
  constructor(body, rawResponse) {
@@ -1593,51 +1457,6 @@ var InternalServerError2 = class _InternalServerError extends LangfuseAPIError {
1593
1457
  }
1594
1458
  };
1595
1459
 
1596
- // src/api/api/resources/unstable/resources/evaluationRules/index.ts
1597
- var evaluationRules_exports2 = {};
1598
- __export(evaluationRules_exports2, {
1599
- EvaluationRuleTimeScope: () => EvaluationRuleTimeScope,
1600
- LegacyEvaluationObject: () => LegacyEvaluationObject2,
1601
- LegacyEvaluationRuleTarget: () => LegacyEvaluationRuleTarget,
1602
- LlmAsJudgeEvaluatorType: () => LlmAsJudgeEvaluatorType
1603
- });
1604
-
1605
- // src/api/api/resources/unstable/resources/evaluationRules/types/LlmAsJudgeEvaluatorType.ts
1606
- var LlmAsJudgeEvaluatorType = {
1607
- LlmAsJudge: "llm_as_judge"
1608
- };
1609
-
1610
- // src/api/api/resources/unstable/resources/evaluationRules/types/EvaluationRuleTimeScope.ts
1611
- var EvaluationRuleTimeScope = {
1612
- New: "NEW",
1613
- Existing: "EXISTING"
1614
- };
1615
-
1616
- // src/api/api/resources/unstable/resources/evaluationRules/types/LegacyEvaluationRuleTarget.ts
1617
- var LegacyEvaluationRuleTarget = {
1618
- Trace: "trace",
1619
- Dataset: "dataset"
1620
- };
1621
-
1622
- // src/api/api/resources/unstable/resources/evaluationRules/types/LegacyEvaluationObject.ts
1623
- var LegacyEvaluationObject2 = {
1624
- Trace: "trace",
1625
- Span: "span",
1626
- Generation: "generation",
1627
- Event: "event",
1628
- Agent: "agent",
1629
- Tool: "tool",
1630
- Chain: "chain",
1631
- Retriever: "retriever",
1632
- Evaluator: "evaluator",
1633
- Embedding: "embedding",
1634
- Guardrail: "guardrail",
1635
- DatasetItem: "dataset_item"
1636
- };
1637
-
1638
- // src/api/api/resources/unstable/resources/evaluators/index.ts
1639
- var evaluators_exports2 = {};
1640
-
1641
1460
  // src/api/api/resources/utils/index.ts
1642
1461
  var utils_exports = {};
1643
1462
  __export(utils_exports, {
@@ -10715,7 +10534,7 @@ var Observations = class {
10715
10534
  * - `time` - completionStartTime, createdAt, updatedAt
10716
10535
  * - `io` - input, output
10717
10536
  * - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
10718
- * - `model` - providedModelName, internalModelId, modelParameters
10537
+ * - `model` - model, internalModelId, modelParameters
10719
10538
  * - `usage` - usageDetails, costDetails, totalCost, usagePricingTierName
10720
10539
  * - `prompt` - promptId, promptName, promptVersion
10721
10540
  * - `metrics` - latency, timeToFirstToken
@@ -17595,1642 +17414,19 @@ var Dashboards = class {
17595
17414
  }
17596
17415
  };
17597
17416
 
17598
- // src/api/api/resources/unstable/resources/evaluationRules/client/Client.ts
17599
- var EvaluationRules2 = class {
17417
+ // src/api/api/resources/unstable/client/Client.ts
17418
+ var Unstable = class {
17600
17419
  constructor(_options) {
17601
17420
  this._options = _options;
17602
17421
  }
17603
- /**
17604
- * Create an evaluation rule.
17605
- *
17606
- * An evaluation rule defines **what** incoming data should be evaluated and **how prompt variables should be populated** from that data.
17607
- *
17608
- * Use this resource after choosing an evaluator from the evaluator endpoints.
17609
- *
17610
- * Key rules:
17611
- * - `name` must be unique within the project for public evaluation rules
17612
- * - `target` must be `observation` or `experiment`
17613
- * - provide either the compatibility `evaluator` field or the new `evaluators` array, never both
17614
- * - each evaluator `name` + `type` must identify an existing evaluator family returned by the evaluator endpoints
17615
- * - Langfuse resolves that family to its latest version before saving the evaluation rule
17616
- * - for `target=experiment`, use dataset `id` values from `GET /api/public/v2/datasets` when filtering by `datasetId`
17617
- * - an omitted LLM-as-judge assignment mapping inherits the evaluator version's default mapping
17618
- * - the effective mapping must map every evaluator prompt variable exactly once
17619
- * - for `code` evaluators, Langfuse uses the fixed code runtime mapping; omit `mapping` in create and update requests
17620
- * - for user-provided `llm_as_judge` mappings, `expected_output` and `experiment_item_metadata` are only valid for `target=experiment`
17621
- * - if `enabled=true`, Langfuse validates that the referenced evaluator can currently run
17622
- * - at most 500 evaluation rules can be effectively active in one project at the same time (enforced identically by the API, the MCP tools, and the app)
17623
- *
17624
- * If an evaluation rule with the same `name` already exists in the project, the API returns `409`.
17625
- * In that case, update the existing resource with `PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}` instead of creating a second one.
17626
- *
17627
- * If enabling this resource would exceed the 500-active limit, the API also returns `409`.
17628
- * In that case, disable or pause another active evaluation rule before enabling a new one.
17629
- *
17630
- * Current scope:
17631
- * - evaluation rules are live-ingestion rules only
17632
- * - they do not trigger historical backfills
17633
- *
17634
- * Recovery guidance:
17635
- * - `400 invalid_filter_value`: fix the filter `column` or `value` using `details.column`, `details.invalidValues`, and `details.allowedValues`
17636
- * - `400 invalid_filter_value` with `details.column=datasetId`: call `GET /api/public/v2/datasets`, then retry with dataset `id` values from that response
17637
- * - `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`
17638
- * - `400 duplicate_variable_mapping`: remove repeated mappings for the same variable
17639
- * - `400 invalid_variable_mapping`: for `llm_as_judge`, switch to a valid `source` for the selected `target`, or fix the variable name
17640
- * - `400 invalid_json_path`: remove or correct the `jsonPath`
17641
- * - `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.
17642
- *
17643
- * @deprecated On Langfuse Cloud, this unstable endpoint is deprecated and will be removed on November 16, 2026. Use the stable `/api/public/v2/evaluation-rules` API instead. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4.
17644
- *
17645
- * @param {LangfuseAPI.unstable.CreateEvaluationRuleRequest} request
17646
- * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
17647
- *
17648
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
17649
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
17650
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
17651
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
17652
- * @throws {@link LangfuseAPI.unstable.ConflictError}
17653
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
17654
- * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
17655
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
17656
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
17657
- * @throws {@link LangfuseAPI.Error}
17658
- * @throws {@link LangfuseAPI.UnauthorizedError}
17659
- * @throws {@link LangfuseAPI.AccessDeniedError}
17660
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
17661
- * @throws {@link LangfuseAPI.NotFoundError}
17662
- *
17663
- * @example
17664
- * await client.unstable.evaluationRules.create({
17665
- * name: "answer-correctness-live",
17666
- * evaluator: {
17667
- * name: "answer-correctness",
17668
- * type: "llm_as_judge"
17669
- * },
17670
- * target: "observation",
17671
- * enabled: true,
17672
- * sampling: 1,
17673
- * filter: [{
17674
- * type: "stringOptions",
17675
- * column: "type",
17676
- * operator: "any of",
17677
- * value: ["GENERATION"]
17678
- * }],
17679
- * mapping: [{
17680
- * variable: "input",
17681
- * source: "input"
17682
- * }, {
17683
- * variable: "output",
17684
- * source: "output"
17685
- * }]
17686
- * })
17687
- *
17688
- * @example
17689
- * await client.unstable.evaluationRules.create({
17690
- * name: "toxicity-code-live",
17691
- * evaluator: {
17692
- * name: "toxicity-detector",
17693
- * type: "code"
17694
- * },
17695
- * target: "observation",
17696
- * enabled: true,
17697
- * sampling: 1,
17698
- * filter: [{
17699
- * type: "stringOptions",
17700
- * column: "type",
17701
- * operator: "any of",
17702
- * value: ["GENERATION"]
17703
- * }]
17704
- * })
17705
- *
17706
- * @example
17707
- * await client.unstable.evaluationRules.create({
17708
- * name: "experiment-expected-output-match",
17709
- * evaluator: {
17710
- * name: "expected-output-match",
17711
- * type: "llm_as_judge"
17712
- * },
17713
- * target: "experiment",
17714
- * enabled: true,
17715
- * sampling: 0.5,
17716
- * filter: [{
17717
- * type: "stringOptions",
17718
- * column: "datasetId",
17719
- * operator: "any of",
17720
- * value: ["550e8400-e29b-41d4-a716-446655440000"]
17721
- * }],
17722
- * mapping: [{
17723
- * variable: "output",
17724
- * source: "output"
17725
- * }, {
17726
- * variable: "expected_output",
17727
- * source: "expected_output"
17728
- * }]
17729
- * })
17730
- */
17731
- create(request, requestOptions) {
17732
- return HttpResponsePromise.fromPromise(
17733
- this.__create(request, requestOptions)
17734
- );
17735
- }
17736
- async __create(request, requestOptions) {
17737
- var _a2, _b, _c, _d, _e, _f, _g, _h;
17738
- let _headers = mergeHeaders(
17739
- (_a2 = this._options) == null ? void 0 : _a2.headers,
17740
- mergeOnlyDefinedHeaders({
17741
- Authorization: await this._getAuthorizationHeader(),
17742
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
17743
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
17744
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
17745
- }),
17746
- requestOptions == null ? void 0 : requestOptions.headers
17747
- );
17748
- const _response = await fetcher({
17749
- url: url_exports.join(
17750
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
17751
- "/api/public/unstable/evaluation-rules"
17752
- ),
17753
- method: "POST",
17754
- headers: _headers,
17755
- contentType: "application/json",
17756
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
17757
- requestType: "json",
17758
- body: request,
17759
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
17760
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
17761
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
17762
- });
17763
- if (_response.ok) {
17764
- return {
17765
- data: _response.body,
17766
- rawResponse: _response.rawResponse
17767
- };
17768
- }
17769
- if (_response.error.reason === "status-code") {
17770
- switch (_response.error.statusCode) {
17771
- case 400:
17772
- throw new unstable_exports.BadRequestError(
17773
- _response.error.body,
17774
- _response.rawResponse
17775
- );
17776
- case 401:
17777
- throw new unstable_exports.UnauthorizedError(
17778
- _response.error.body,
17779
- _response.rawResponse
17780
- );
17781
- case 403:
17782
- throw new unstable_exports.AccessDeniedError(
17783
- _response.error.body,
17784
- _response.rawResponse
17785
- );
17786
- case 404:
17787
- throw new unstable_exports.NotFoundError(
17788
- _response.error.body,
17789
- _response.rawResponse
17790
- );
17791
- case 409:
17792
- throw new unstable_exports.ConflictError(
17793
- _response.error.body,
17794
- _response.rawResponse
17795
- );
17796
- case 405:
17797
- throw new unstable_exports.MethodNotAllowedError(
17798
- _response.error.body,
17799
- _response.rawResponse
17800
- );
17801
- case 422:
17802
- throw new unstable_exports.UnprocessableContentError(
17803
- _response.error.body,
17804
- _response.rawResponse
17805
- );
17806
- case 429:
17807
- throw new unstable_exports.TooManyRequestsError(
17808
- _response.error.body,
17809
- _response.rawResponse
17810
- );
17811
- case 500:
17812
- throw new unstable_exports.InternalServerError(
17813
- _response.error.body,
17814
- _response.rawResponse
17815
- );
17816
- case 400:
17817
- throw new Error2(
17818
- _response.error.body,
17819
- _response.rawResponse
17820
- );
17821
- case 401:
17822
- throw new UnauthorizedError(
17823
- _response.error.body,
17824
- _response.rawResponse
17825
- );
17826
- case 403:
17827
- throw new AccessDeniedError(
17828
- _response.error.body,
17829
- _response.rawResponse
17830
- );
17831
- case 405:
17832
- throw new MethodNotAllowedError(
17833
- _response.error.body,
17834
- _response.rawResponse
17835
- );
17836
- case 404:
17837
- throw new NotFoundError(
17838
- _response.error.body,
17839
- _response.rawResponse
17840
- );
17841
- default:
17842
- throw new LangfuseAPIError({
17843
- statusCode: _response.error.statusCode,
17844
- body: _response.error.body,
17845
- rawResponse: _response.rawResponse
17846
- });
17847
- }
17848
- }
17849
- switch (_response.error.reason) {
17850
- case "non-json":
17851
- throw new LangfuseAPIError({
17852
- statusCode: _response.error.statusCode,
17853
- body: _response.error.rawBody,
17854
- rawResponse: _response.rawResponse
17855
- });
17856
- case "timeout":
17857
- throw new LangfuseAPITimeoutError(
17858
- "Timeout exceeded when calling POST /api/public/unstable/evaluation-rules."
17859
- );
17860
- case "unknown":
17861
- throw new LangfuseAPIError({
17862
- message: _response.error.errorMessage,
17863
- rawResponse: _response.rawResponse
17864
- });
17865
- }
17866
- }
17867
- /**
17868
- * List evaluation rules in the authenticated project.
17869
- *
17870
- * This includes legacy `trace` and `dataset` rules so they can be inspected and migrated to v4 rules. Legacy rules are read-only through this API; create, update, and delete continue to support only `observation` and `experiment` rules.
17871
- *
17872
- * @deprecated On Langfuse Cloud, this unstable endpoint is deprecated and will be removed on November 16, 2026. Use the stable `/api/public/v2/evaluation-rules` API instead. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4.
17873
- *
17874
- * @param {LangfuseAPI.unstable.ListEvaluationRulesRequest} request
17875
- * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
17876
- *
17877
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
17878
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
17879
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
17880
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
17881
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
17882
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
17883
- * @throws {@link LangfuseAPI.Error}
17884
- * @throws {@link LangfuseAPI.UnauthorizedError}
17885
- * @throws {@link LangfuseAPI.AccessDeniedError}
17886
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
17887
- * @throws {@link LangfuseAPI.NotFoundError}
17888
- *
17889
- * @example
17890
- * await client.unstable.evaluationRules.list()
17891
- */
17892
- list(request = {}, requestOptions) {
17893
- return HttpResponsePromise.fromPromise(
17894
- this.__list(request, requestOptions)
17895
- );
17896
- }
17897
- async __list(request = {}, requestOptions) {
17898
- var _a2, _b, _c, _d, _e, _f, _g, _h;
17899
- const { page, limit } = request;
17900
- const _queryParams = {};
17901
- if (page != null) {
17902
- _queryParams["page"] = page.toString();
17903
- }
17904
- if (limit != null) {
17905
- _queryParams["limit"] = limit.toString();
17906
- }
17907
- let _headers = mergeHeaders(
17908
- (_a2 = this._options) == null ? void 0 : _a2.headers,
17909
- mergeOnlyDefinedHeaders({
17910
- Authorization: await this._getAuthorizationHeader(),
17911
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
17912
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
17913
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
17914
- }),
17915
- requestOptions == null ? void 0 : requestOptions.headers
17916
- );
17917
- const _response = await fetcher({
17918
- url: url_exports.join(
17919
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
17920
- "/api/public/unstable/evaluation-rules"
17921
- ),
17922
- method: "GET",
17923
- headers: _headers,
17924
- queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
17925
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
17926
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
17927
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
17928
- });
17929
- if (_response.ok) {
17930
- return {
17931
- data: _response.body,
17932
- rawResponse: _response.rawResponse
17933
- };
17934
- }
17935
- if (_response.error.reason === "status-code") {
17936
- switch (_response.error.statusCode) {
17937
- case 400:
17938
- throw new unstable_exports.BadRequestError(
17939
- _response.error.body,
17940
- _response.rawResponse
17941
- );
17942
- case 401:
17943
- throw new unstable_exports.UnauthorizedError(
17944
- _response.error.body,
17945
- _response.rawResponse
17946
- );
17947
- case 403:
17948
- throw new unstable_exports.AccessDeniedError(
17949
- _response.error.body,
17950
- _response.rawResponse
17951
- );
17952
- case 405:
17953
- throw new unstable_exports.MethodNotAllowedError(
17954
- _response.error.body,
17955
- _response.rawResponse
17956
- );
17957
- case 429:
17958
- throw new unstable_exports.TooManyRequestsError(
17959
- _response.error.body,
17960
- _response.rawResponse
17961
- );
17962
- case 500:
17963
- throw new unstable_exports.InternalServerError(
17964
- _response.error.body,
17965
- _response.rawResponse
17966
- );
17967
- case 400:
17968
- throw new Error2(
17969
- _response.error.body,
17970
- _response.rawResponse
17971
- );
17972
- case 401:
17973
- throw new UnauthorizedError(
17974
- _response.error.body,
17975
- _response.rawResponse
17976
- );
17977
- case 403:
17978
- throw new AccessDeniedError(
17979
- _response.error.body,
17980
- _response.rawResponse
17981
- );
17982
- case 405:
17983
- throw new MethodNotAllowedError(
17984
- _response.error.body,
17985
- _response.rawResponse
17986
- );
17987
- case 404:
17988
- throw new NotFoundError(
17989
- _response.error.body,
17990
- _response.rawResponse
17991
- );
17992
- default:
17993
- throw new LangfuseAPIError({
17994
- statusCode: _response.error.statusCode,
17995
- body: _response.error.body,
17996
- rawResponse: _response.rawResponse
17997
- });
17998
- }
17999
- }
18000
- switch (_response.error.reason) {
18001
- case "non-json":
18002
- throw new LangfuseAPIError({
18003
- statusCode: _response.error.statusCode,
18004
- body: _response.error.rawBody,
18005
- rawResponse: _response.rawResponse
18006
- });
18007
- case "timeout":
18008
- throw new LangfuseAPITimeoutError(
18009
- "Timeout exceeded when calling GET /api/public/unstable/evaluation-rules."
18010
- );
18011
- case "unknown":
18012
- throw new LangfuseAPIError({
18013
- message: _response.error.errorMessage,
18014
- rawResponse: _response.rawResponse
18015
- });
18016
- }
18017
- }
18018
- /**
18019
- * Get one evaluation rule by its identifier.
18020
- *
18021
- * Use this endpoint to inspect the current evaluator, target, mapping, filters, execution timing, and effective runtime status. Legacy `trace` and `dataset` rules are returned for migration and are read-only through this API.
18022
- *
18023
- * @deprecated On Langfuse Cloud, this unstable endpoint is deprecated and will be removed on November 16, 2026. Use the stable `/api/public/v2/evaluation-rules` API instead. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4.
18024
- *
18025
- * @param {string} evaluationRuleId - Evaluation rule identifier returned by the evaluation rule endpoints.
18026
- * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
18027
- *
18028
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18029
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18030
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18031
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
18032
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18033
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18034
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18035
- * @throws {@link LangfuseAPI.Error}
18036
- * @throws {@link LangfuseAPI.UnauthorizedError}
18037
- * @throws {@link LangfuseAPI.AccessDeniedError}
18038
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18039
- * @throws {@link LangfuseAPI.NotFoundError}
18040
- *
18041
- * @example
18042
- * await client.unstable.evaluationRules.get("evaluationRuleId")
18043
- */
18044
- get(evaluationRuleId, requestOptions) {
18045
- return HttpResponsePromise.fromPromise(
18046
- this.__get(evaluationRuleId, requestOptions)
18047
- );
18048
- }
18049
- async __get(evaluationRuleId, requestOptions) {
18050
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18051
- let _headers = mergeHeaders(
18052
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18053
- mergeOnlyDefinedHeaders({
18054
- Authorization: await this._getAuthorizationHeader(),
18055
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18056
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18057
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18058
- }),
18059
- requestOptions == null ? void 0 : requestOptions.headers
18060
- );
18061
- const _response = await fetcher({
18062
- url: url_exports.join(
18063
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18064
- `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
18065
- ),
18066
- method: "GET",
18067
- headers: _headers,
18068
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
18069
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18070
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18071
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18072
- });
18073
- if (_response.ok) {
18074
- return {
18075
- data: _response.body,
18076
- rawResponse: _response.rawResponse
18077
- };
18078
- }
18079
- if (_response.error.reason === "status-code") {
18080
- switch (_response.error.statusCode) {
18081
- case 400:
18082
- throw new unstable_exports.BadRequestError(
18083
- _response.error.body,
18084
- _response.rawResponse
18085
- );
18086
- case 401:
18087
- throw new unstable_exports.UnauthorizedError(
18088
- _response.error.body,
18089
- _response.rawResponse
18090
- );
18091
- case 403:
18092
- throw new unstable_exports.AccessDeniedError(
18093
- _response.error.body,
18094
- _response.rawResponse
18095
- );
18096
- case 404:
18097
- throw new unstable_exports.NotFoundError(
18098
- _response.error.body,
18099
- _response.rawResponse
18100
- );
18101
- case 405:
18102
- throw new unstable_exports.MethodNotAllowedError(
18103
- _response.error.body,
18104
- _response.rawResponse
18105
- );
18106
- case 429:
18107
- throw new unstable_exports.TooManyRequestsError(
18108
- _response.error.body,
18109
- _response.rawResponse
18110
- );
18111
- case 500:
18112
- throw new unstable_exports.InternalServerError(
18113
- _response.error.body,
18114
- _response.rawResponse
18115
- );
18116
- case 400:
18117
- throw new Error2(
18118
- _response.error.body,
18119
- _response.rawResponse
18120
- );
18121
- case 401:
18122
- throw new UnauthorizedError(
18123
- _response.error.body,
18124
- _response.rawResponse
18125
- );
18126
- case 403:
18127
- throw new AccessDeniedError(
18128
- _response.error.body,
18129
- _response.rawResponse
18130
- );
18131
- case 405:
18132
- throw new MethodNotAllowedError(
18133
- _response.error.body,
18134
- _response.rawResponse
18135
- );
18136
- case 404:
18137
- throw new NotFoundError(
18138
- _response.error.body,
18139
- _response.rawResponse
18140
- );
18141
- default:
18142
- throw new LangfuseAPIError({
18143
- statusCode: _response.error.statusCode,
18144
- body: _response.error.body,
18145
- rawResponse: _response.rawResponse
18146
- });
18147
- }
18148
- }
18149
- switch (_response.error.reason) {
18150
- case "non-json":
18151
- throw new LangfuseAPIError({
18152
- statusCode: _response.error.statusCode,
18153
- body: _response.error.rawBody,
18154
- rawResponse: _response.rawResponse
18155
- });
18156
- case "timeout":
18157
- throw new LangfuseAPITimeoutError(
18158
- "Timeout exceeded when calling GET /api/public/unstable/evaluation-rules/{evaluationRuleId}."
18159
- );
18160
- case "unknown":
18161
- throw new LangfuseAPIError({
18162
- message: _response.error.errorMessage,
18163
- rawResponse: _response.rawResponse
18164
- });
18165
- }
18166
- }
18167
- /**
18168
- * Update an evaluation rule.
18169
- *
18170
- * Typical uses:
18171
- * - enable or disable live execution
18172
- * - switch to another evaluator
18173
- * - adjust sampling
18174
- * - change filters
18175
- * - update LLM-as-judge variable mappings
18176
- *
18177
- * Important behavior:
18178
- * - provide only the fields you want to change
18179
- * - if you provide `evaluator`, Langfuse resolves that evaluator family to its latest version before saving
18180
- * - changing `target`, `filter`, or an LLM-as-judge `mapping` must still produce a valid target-specific configuration
18181
- * - 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
18182
- * - for `code` evaluator rules, omit `mapping`; Langfuse stores the fixed code runtime mapping automatically
18183
- * - if the resulting config is enabled, Langfuse re-validates that the selected evaluator can run
18184
- * - if the update would move a non-active evaluation rule into the active state and the project already has 500 active evaluation rules, the API returns `409`
18185
- *
18186
- * Recovery guidance:
18187
- * - 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`
18188
- * - if the update fails with `invalid_filter_value` after changing `target`, resend the request with a target-compatible `filter`
18189
- *
18190
- * @deprecated On Langfuse Cloud, this unstable endpoint is deprecated and will be removed on November 16, 2026. Use the stable `/api/public/v2/evaluation-rules` API instead. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4.
18191
- *
18192
- * @param {string} evaluationRuleId - Evaluation rule identifier.
18193
- * @param {LangfuseAPI.unstable.UpdateEvaluationRuleRequest} request
18194
- * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
18195
- *
18196
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18197
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18198
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18199
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
18200
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18201
- * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
18202
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18203
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18204
- * @throws {@link LangfuseAPI.Error}
18205
- * @throws {@link LangfuseAPI.UnauthorizedError}
18206
- * @throws {@link LangfuseAPI.AccessDeniedError}
18207
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18208
- * @throws {@link LangfuseAPI.NotFoundError}
18209
- *
18210
- * @example
18211
- * await client.unstable.evaluationRules.update("evaluationRuleId", {
18212
- * name: undefined,
18213
- * evaluators: undefined,
18214
- * evaluator: undefined,
18215
- * target: undefined,
18216
- * enabled: undefined,
18217
- * sampling: undefined,
18218
- * filter: undefined,
18219
- * mapping: undefined
18220
- * })
18221
- */
18222
- update(evaluationRuleId, request, requestOptions) {
18223
- return HttpResponsePromise.fromPromise(
18224
- this.__update(evaluationRuleId, request, requestOptions)
18225
- );
18226
- }
18227
- async __update(evaluationRuleId, request, requestOptions) {
18228
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18229
- let _headers = mergeHeaders(
18230
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18231
- mergeOnlyDefinedHeaders({
18232
- Authorization: await this._getAuthorizationHeader(),
18233
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18234
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18235
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18236
- }),
18237
- requestOptions == null ? void 0 : requestOptions.headers
18238
- );
18239
- const _response = await fetcher({
18240
- url: url_exports.join(
18241
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18242
- `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
18243
- ),
18244
- method: "PATCH",
18245
- headers: _headers,
18246
- contentType: "application/json",
18247
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
18248
- requestType: "json",
18249
- body: request,
18250
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18251
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18252
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18253
- });
18254
- if (_response.ok) {
18255
- return {
18256
- data: _response.body,
18257
- rawResponse: _response.rawResponse
18258
- };
18259
- }
18260
- if (_response.error.reason === "status-code") {
18261
- switch (_response.error.statusCode) {
18262
- case 400:
18263
- throw new unstable_exports.BadRequestError(
18264
- _response.error.body,
18265
- _response.rawResponse
18266
- );
18267
- case 401:
18268
- throw new unstable_exports.UnauthorizedError(
18269
- _response.error.body,
18270
- _response.rawResponse
18271
- );
18272
- case 403:
18273
- throw new unstable_exports.AccessDeniedError(
18274
- _response.error.body,
18275
- _response.rawResponse
18276
- );
18277
- case 404:
18278
- throw new unstable_exports.NotFoundError(
18279
- _response.error.body,
18280
- _response.rawResponse
18281
- );
18282
- case 405:
18283
- throw new unstable_exports.MethodNotAllowedError(
18284
- _response.error.body,
18285
- _response.rawResponse
18286
- );
18287
- case 422:
18288
- throw new unstable_exports.UnprocessableContentError(
18289
- _response.error.body,
18290
- _response.rawResponse
18291
- );
18292
- case 429:
18293
- throw new unstable_exports.TooManyRequestsError(
18294
- _response.error.body,
18295
- _response.rawResponse
18296
- );
18297
- case 500:
18298
- throw new unstable_exports.InternalServerError(
18299
- _response.error.body,
18300
- _response.rawResponse
18301
- );
18302
- case 400:
18303
- throw new Error2(
18304
- _response.error.body,
18305
- _response.rawResponse
18306
- );
18307
- case 401:
18308
- throw new UnauthorizedError(
18309
- _response.error.body,
18310
- _response.rawResponse
18311
- );
18312
- case 403:
18313
- throw new AccessDeniedError(
18314
- _response.error.body,
18315
- _response.rawResponse
18316
- );
18317
- case 405:
18318
- throw new MethodNotAllowedError(
18319
- _response.error.body,
18320
- _response.rawResponse
18321
- );
18322
- case 404:
18323
- throw new NotFoundError(
18324
- _response.error.body,
18325
- _response.rawResponse
18326
- );
18327
- default:
18328
- throw new LangfuseAPIError({
18329
- statusCode: _response.error.statusCode,
18330
- body: _response.error.body,
18331
- rawResponse: _response.rawResponse
18332
- });
18333
- }
18334
- }
18335
- switch (_response.error.reason) {
18336
- case "non-json":
18337
- throw new LangfuseAPIError({
18338
- statusCode: _response.error.statusCode,
18339
- body: _response.error.rawBody,
18340
- rawResponse: _response.rawResponse
18341
- });
18342
- case "timeout":
18343
- throw new LangfuseAPITimeoutError(
18344
- "Timeout exceeded when calling PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}."
18345
- );
18346
- case "unknown":
18347
- throw new LangfuseAPIError({
18348
- message: _response.error.errorMessage,
18349
- rawResponse: _response.rawResponse
18350
- });
18351
- }
18352
- }
18353
- /**
18354
- * Delete an evaluation rule.
18355
- *
18356
- * This removes the live-ingestion rule only. It does not delete the referenced evaluator.
18357
- *
18358
- * @deprecated On Langfuse Cloud, this unstable endpoint is deprecated and will be removed on November 16, 2026. Use the stable `/api/public/v2/evaluation-rules` API instead. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4.
18359
- *
18360
- * @param {string} evaluationRuleId - Evaluation rule identifier.
18361
- * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
18362
- *
18363
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18364
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18365
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18366
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
18367
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18368
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18369
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18370
- * @throws {@link LangfuseAPI.Error}
18371
- * @throws {@link LangfuseAPI.UnauthorizedError}
18372
- * @throws {@link LangfuseAPI.AccessDeniedError}
18373
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18374
- * @throws {@link LangfuseAPI.NotFoundError}
18375
- *
18376
- * @example
18377
- * await client.unstable.evaluationRules.delete("evaluationRuleId")
18378
- */
18379
- delete(evaluationRuleId, requestOptions) {
18380
- return HttpResponsePromise.fromPromise(
18381
- this.__delete(evaluationRuleId, requestOptions)
18382
- );
18383
- }
18384
- async __delete(evaluationRuleId, requestOptions) {
18385
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18386
- let _headers = mergeHeaders(
18387
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18388
- mergeOnlyDefinedHeaders({
18389
- Authorization: await this._getAuthorizationHeader(),
18390
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18391
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18392
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18393
- }),
18394
- requestOptions == null ? void 0 : requestOptions.headers
18395
- );
18396
- const _response = await fetcher({
18397
- url: url_exports.join(
18398
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18399
- `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
18400
- ),
18401
- method: "DELETE",
18402
- headers: _headers,
18403
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
18404
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18405
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18406
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18407
- });
18408
- if (_response.ok) {
18409
- return {
18410
- data: _response.body,
18411
- rawResponse: _response.rawResponse
18412
- };
18413
- }
18414
- if (_response.error.reason === "status-code") {
18415
- switch (_response.error.statusCode) {
18416
- case 400:
18417
- throw new unstable_exports.BadRequestError(
18418
- _response.error.body,
18419
- _response.rawResponse
18420
- );
18421
- case 401:
18422
- throw new unstable_exports.UnauthorizedError(
18423
- _response.error.body,
18424
- _response.rawResponse
18425
- );
18426
- case 403:
18427
- throw new unstable_exports.AccessDeniedError(
18428
- _response.error.body,
18429
- _response.rawResponse
18430
- );
18431
- case 404:
18432
- throw new unstable_exports.NotFoundError(
18433
- _response.error.body,
18434
- _response.rawResponse
18435
- );
18436
- case 405:
18437
- throw new unstable_exports.MethodNotAllowedError(
18438
- _response.error.body,
18439
- _response.rawResponse
18440
- );
18441
- case 429:
18442
- throw new unstable_exports.TooManyRequestsError(
18443
- _response.error.body,
18444
- _response.rawResponse
18445
- );
18446
- case 500:
18447
- throw new unstable_exports.InternalServerError(
18448
- _response.error.body,
18449
- _response.rawResponse
18450
- );
18451
- case 400:
18452
- throw new Error2(
18453
- _response.error.body,
18454
- _response.rawResponse
18455
- );
18456
- case 401:
18457
- throw new UnauthorizedError(
18458
- _response.error.body,
18459
- _response.rawResponse
18460
- );
18461
- case 403:
18462
- throw new AccessDeniedError(
18463
- _response.error.body,
18464
- _response.rawResponse
18465
- );
18466
- case 405:
18467
- throw new MethodNotAllowedError(
18468
- _response.error.body,
18469
- _response.rawResponse
18470
- );
18471
- case 404:
18472
- throw new NotFoundError(
18473
- _response.error.body,
18474
- _response.rawResponse
18475
- );
18476
- default:
18477
- throw new LangfuseAPIError({
18478
- statusCode: _response.error.statusCode,
18479
- body: _response.error.body,
18480
- rawResponse: _response.rawResponse
18481
- });
18482
- }
18483
- }
18484
- switch (_response.error.reason) {
18485
- case "non-json":
18486
- throw new LangfuseAPIError({
18487
- statusCode: _response.error.statusCode,
18488
- body: _response.error.rawBody,
18489
- rawResponse: _response.rawResponse
18490
- });
18491
- case "timeout":
18492
- throw new LangfuseAPITimeoutError(
18493
- "Timeout exceeded when calling DELETE /api/public/unstable/evaluation-rules/{evaluationRuleId}."
18494
- );
18495
- case "unknown":
18496
- throw new LangfuseAPIError({
18497
- message: _response.error.errorMessage,
18498
- rawResponse: _response.rawResponse
18499
- });
18500
- }
18501
- }
18502
- async _getAuthorizationHeader() {
18503
- const username = await Supplier.get(this._options.username);
18504
- const password = await Supplier.get(this._options.password);
18505
- if (username != null && password != null) {
18506
- return BasicAuth.toAuthorizationHeader({
18507
- username,
18508
- password
18509
- });
18510
- }
18511
- return void 0;
18512
- }
18513
- };
18514
-
18515
- // src/api/api/resources/unstable/resources/evaluators/client/Client.ts
18516
- var Evaluators2 = class {
18517
- constructor(_options) {
18518
- this._options = _options;
18519
- }
18520
- /**
18521
- * Create an evaluator in the authenticated project.
18522
- *
18523
- * Use evaluators to define **how** Langfuse should score data.
18524
- * LLM-as-a-judge evaluators define a prompt, expected structured output, and optional model configuration.
18525
- * Code evaluators define source code and a runtime language.
18526
- *
18527
- * Naming behavior:
18528
- * - If this is a new evaluator name in your project, Langfuse creates version `1`.
18529
- * - If the name already exists in your project, Langfuse creates the next version and returns it.
18530
- * - The evaluator `id` remains stable across versions.
18531
- * - Existing evaluation rules automatically use the latest evaluator version; no rule update is required.
18532
- *
18533
- * Recommended workflow:
18534
- * 1. Create the evaluator.
18535
- * 2. Read the returned `variables` array.
18536
- * 3. Read the returned `outputDefinition.dataType` so the client knows whether future scores will be numeric, boolean, or categorical.
18537
- * 4. Create one or more evaluation rules that reference the returned evaluator family using `name` and `type`.
18538
- *
18539
- * Code evaluator validation:
18540
- * - At creation, Langfuse only validates the request shape
18541
- * - 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.
18542
- *
18543
- * Recovery guidance:
18544
- * - `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.
18545
- * - `400` with `code=invalid_body`: the request shape is malformed. Use the structured `details.issues` array to fix the specific fields and retry.
18546
- * - `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.
18547
- * - If `type` is omitted, Langfuse treats the request as `type=llm_as_judge` for backwards compatibility. New clients should send `type` explicitly.
18548
- *
18549
- * Unstable API note:
18550
- * - This surface may evolve while the underlying evaluation data model is being redesigned.
18551
- *
18552
- * @deprecated On Langfuse Cloud, this unstable endpoint is deprecated and will be removed on November 16, 2026. Use the stable `/api/public/v2/evaluators` API instead. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4.
18553
- *
18554
- * @param {LangfuseAPI.unstable.CreateEvaluatorRequest} request
18555
- * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
18556
- *
18557
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18558
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18559
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18560
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18561
- * @throws {@link LangfuseAPI.unstable.ConflictError}
18562
- * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
18563
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18564
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18565
- * @throws {@link LangfuseAPI.Error}
18566
- * @throws {@link LangfuseAPI.UnauthorizedError}
18567
- * @throws {@link LangfuseAPI.AccessDeniedError}
18568
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18569
- * @throws {@link LangfuseAPI.NotFoundError}
18570
- *
18571
- * @example
18572
- * await client.unstable.evaluators.create({
18573
- * type: "llm_as_judge",
18574
- * name: "answer-correctness",
18575
- * prompt: "You are grading an answer.\n\nInput:\n{{input}}\n\nOutput:\n{{output}}\n\nReturn a score between 0 and 1.\n",
18576
- * outputDefinition: {
18577
- * dataType: "NUMERIC",
18578
- * dataType: "NUMERIC",
18579
- * reasoning: {
18580
- * description: "Explain why the score was assigned."
18581
- * },
18582
- * score: {
18583
- * description: "Correctness score between 0 and 1."
18584
- * }
18585
- * },
18586
- * modelConfig: {
18587
- * provider: "openai",
18588
- * model: "gpt-4.1-mini"
18589
- * },
18590
- * mapping: [{
18591
- * variable: "input",
18592
- * source: "input"
18593
- * }, {
18594
- * variable: "output",
18595
- * source: "output"
18596
- * }]
18597
- * })
18598
- *
18599
- * @example
18600
- * await client.unstable.evaluators.create({
18601
- * type: "code",
18602
- * name: "exact-match",
18603
- * 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",
18604
- * sourceCodeLanguage: "TYPESCRIPT"
18605
- * })
18606
- *
18607
- * @example
18608
- * await client.unstable.evaluators.create({
18609
- * type: "code",
18610
- * name: "exact-match",
18611
- * 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",
18612
- * sourceCodeLanguage: "PYTHON"
18613
- * })
18614
- */
18615
- create(request, requestOptions) {
18616
- return HttpResponsePromise.fromPromise(
18617
- this.__create(request, requestOptions)
18618
- );
18619
- }
18620
- async __create(request, requestOptions) {
18621
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18622
- let _headers = mergeHeaders(
18623
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18624
- mergeOnlyDefinedHeaders({
18625
- Authorization: await this._getAuthorizationHeader(),
18626
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18627
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18628
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18629
- }),
18630
- requestOptions == null ? void 0 : requestOptions.headers
18631
- );
18632
- const _response = await fetcher({
18633
- url: url_exports.join(
18634
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18635
- "/api/public/unstable/evaluators"
18636
- ),
18637
- method: "POST",
18638
- headers: _headers,
18639
- contentType: "application/json",
18640
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
18641
- requestType: "json",
18642
- body: request,
18643
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18644
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18645
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18646
- });
18647
- if (_response.ok) {
18648
- return {
18649
- data: _response.body,
18650
- rawResponse: _response.rawResponse
18651
- };
18652
- }
18653
- if (_response.error.reason === "status-code") {
18654
- switch (_response.error.statusCode) {
18655
- case 400:
18656
- throw new unstable_exports.BadRequestError(
18657
- _response.error.body,
18658
- _response.rawResponse
18659
- );
18660
- case 401:
18661
- throw new unstable_exports.UnauthorizedError(
18662
- _response.error.body,
18663
- _response.rawResponse
18664
- );
18665
- case 403:
18666
- throw new unstable_exports.AccessDeniedError(
18667
- _response.error.body,
18668
- _response.rawResponse
18669
- );
18670
- case 405:
18671
- throw new unstable_exports.MethodNotAllowedError(
18672
- _response.error.body,
18673
- _response.rawResponse
18674
- );
18675
- case 409:
18676
- throw new unstable_exports.ConflictError(
18677
- _response.error.body,
18678
- _response.rawResponse
18679
- );
18680
- case 422:
18681
- throw new unstable_exports.UnprocessableContentError(
18682
- _response.error.body,
18683
- _response.rawResponse
18684
- );
18685
- case 429:
18686
- throw new unstable_exports.TooManyRequestsError(
18687
- _response.error.body,
18688
- _response.rawResponse
18689
- );
18690
- case 500:
18691
- throw new unstable_exports.InternalServerError(
18692
- _response.error.body,
18693
- _response.rawResponse
18694
- );
18695
- case 400:
18696
- throw new Error2(
18697
- _response.error.body,
18698
- _response.rawResponse
18699
- );
18700
- case 401:
18701
- throw new UnauthorizedError(
18702
- _response.error.body,
18703
- _response.rawResponse
18704
- );
18705
- case 403:
18706
- throw new AccessDeniedError(
18707
- _response.error.body,
18708
- _response.rawResponse
18709
- );
18710
- case 405:
18711
- throw new MethodNotAllowedError(
18712
- _response.error.body,
18713
- _response.rawResponse
18714
- );
18715
- case 404:
18716
- throw new NotFoundError(
18717
- _response.error.body,
18718
- _response.rawResponse
18719
- );
18720
- default:
18721
- throw new LangfuseAPIError({
18722
- statusCode: _response.error.statusCode,
18723
- body: _response.error.body,
18724
- rawResponse: _response.rawResponse
18725
- });
18726
- }
18727
- }
18728
- switch (_response.error.reason) {
18729
- case "non-json":
18730
- throw new LangfuseAPIError({
18731
- statusCode: _response.error.statusCode,
18732
- body: _response.error.rawBody,
18733
- rawResponse: _response.rawResponse
18734
- });
18735
- case "timeout":
18736
- throw new LangfuseAPITimeoutError(
18737
- "Timeout exceeded when calling POST /api/public/unstable/evaluators."
18738
- );
18739
- case "unknown":
18740
- throw new LangfuseAPIError({
18741
- message: _response.error.errorMessage,
18742
- rawResponse: _response.rawResponse
18743
- });
18744
- }
18745
- }
18746
- /**
18747
- * List the evaluators available to the authenticated project.
18748
- *
18749
- * Important behavior:
18750
- * - This endpoint returns the latest version of each available evaluator.
18751
- * - Every evaluator is owned by the authenticated project.
18752
- *
18753
- * @deprecated On Langfuse Cloud, this unstable endpoint is deprecated and will be removed on November 16, 2026. Use the stable `/api/public/v2/evaluators` API instead. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4.
18754
- *
18755
- * @param {LangfuseAPI.unstable.ListEvaluatorsRequest} request
18756
- * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
18757
- *
18758
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18759
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18760
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18761
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18762
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18763
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18764
- * @throws {@link LangfuseAPI.Error}
18765
- * @throws {@link LangfuseAPI.UnauthorizedError}
18766
- * @throws {@link LangfuseAPI.AccessDeniedError}
18767
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18768
- * @throws {@link LangfuseAPI.NotFoundError}
18769
- *
18770
- * @example
18771
- * await client.unstable.evaluators.list()
18772
- */
18773
- list(request = {}, requestOptions) {
18774
- return HttpResponsePromise.fromPromise(
18775
- this.__list(request, requestOptions)
18776
- );
18777
- }
18778
- async __list(request = {}, requestOptions) {
18779
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18780
- const { page, limit } = request;
18781
- const _queryParams = {};
18782
- if (page != null) {
18783
- _queryParams["page"] = page.toString();
18784
- }
18785
- if (limit != null) {
18786
- _queryParams["limit"] = limit.toString();
18787
- }
18788
- let _headers = mergeHeaders(
18789
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18790
- mergeOnlyDefinedHeaders({
18791
- Authorization: await this._getAuthorizationHeader(),
18792
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18793
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18794
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18795
- }),
18796
- requestOptions == null ? void 0 : requestOptions.headers
18797
- );
18798
- const _response = await fetcher({
18799
- url: url_exports.join(
18800
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18801
- "/api/public/unstable/evaluators"
18802
- ),
18803
- method: "GET",
18804
- headers: _headers,
18805
- queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
18806
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18807
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18808
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18809
- });
18810
- if (_response.ok) {
18811
- return {
18812
- data: _response.body,
18813
- rawResponse: _response.rawResponse
18814
- };
18815
- }
18816
- if (_response.error.reason === "status-code") {
18817
- switch (_response.error.statusCode) {
18818
- case 400:
18819
- throw new unstable_exports.BadRequestError(
18820
- _response.error.body,
18821
- _response.rawResponse
18822
- );
18823
- case 401:
18824
- throw new unstable_exports.UnauthorizedError(
18825
- _response.error.body,
18826
- _response.rawResponse
18827
- );
18828
- case 403:
18829
- throw new unstable_exports.AccessDeniedError(
18830
- _response.error.body,
18831
- _response.rawResponse
18832
- );
18833
- case 405:
18834
- throw new unstable_exports.MethodNotAllowedError(
18835
- _response.error.body,
18836
- _response.rawResponse
18837
- );
18838
- case 429:
18839
- throw new unstable_exports.TooManyRequestsError(
18840
- _response.error.body,
18841
- _response.rawResponse
18842
- );
18843
- case 500:
18844
- throw new unstable_exports.InternalServerError(
18845
- _response.error.body,
18846
- _response.rawResponse
18847
- );
18848
- case 400:
18849
- throw new Error2(
18850
- _response.error.body,
18851
- _response.rawResponse
18852
- );
18853
- case 401:
18854
- throw new UnauthorizedError(
18855
- _response.error.body,
18856
- _response.rawResponse
18857
- );
18858
- case 403:
18859
- throw new AccessDeniedError(
18860
- _response.error.body,
18861
- _response.rawResponse
18862
- );
18863
- case 405:
18864
- throw new MethodNotAllowedError(
18865
- _response.error.body,
18866
- _response.rawResponse
18867
- );
18868
- case 404:
18869
- throw new NotFoundError(
18870
- _response.error.body,
18871
- _response.rawResponse
18872
- );
18873
- default:
18874
- throw new LangfuseAPIError({
18875
- statusCode: _response.error.statusCode,
18876
- body: _response.error.body,
18877
- rawResponse: _response.rawResponse
18878
- });
18879
- }
18880
- }
18881
- switch (_response.error.reason) {
18882
- case "non-json":
18883
- throw new LangfuseAPIError({
18884
- statusCode: _response.error.statusCode,
18885
- body: _response.error.rawBody,
18886
- rawResponse: _response.rawResponse
18887
- });
18888
- case "timeout":
18889
- throw new LangfuseAPITimeoutError(
18890
- "Timeout exceeded when calling GET /api/public/unstable/evaluators."
18891
- );
18892
- case "unknown":
18893
- throw new LangfuseAPIError({
18894
- message: _response.error.errorMessage,
18895
- rawResponse: _response.rawResponse
18896
- });
18897
- }
18898
- }
18899
- /**
18900
- * Get one evaluator by `id`.
18901
- *
18902
- * This endpoint always returns the evaluator's latest version. Use it when you want the current prompt, output definition, model configuration, and derived variables for the evaluator you plan to use in an evaluation rule.
18903
- *
18904
- * @deprecated On Langfuse Cloud, this unstable endpoint is deprecated and will be removed on November 16, 2026. Use the stable `/api/public/v2/evaluators` API instead. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4.
18905
- *
18906
- * @param {string} evaluatorId - Evaluator identifier returned by the evaluator endpoints.
18907
- * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
18908
- *
18909
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18910
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18911
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18912
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
18913
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18914
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18915
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18916
- * @throws {@link LangfuseAPI.Error}
18917
- * @throws {@link LangfuseAPI.UnauthorizedError}
18918
- * @throws {@link LangfuseAPI.AccessDeniedError}
18919
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18920
- * @throws {@link LangfuseAPI.NotFoundError}
18921
- *
18922
- * @example
18923
- * await client.unstable.evaluators.get("evaluatorId")
18924
- */
18925
- get(evaluatorId, requestOptions) {
18926
- return HttpResponsePromise.fromPromise(
18927
- this.__get(evaluatorId, requestOptions)
18928
- );
18929
- }
18930
- async __get(evaluatorId, requestOptions) {
18931
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18932
- let _headers = mergeHeaders(
18933
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18934
- mergeOnlyDefinedHeaders({
18935
- Authorization: await this._getAuthorizationHeader(),
18936
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18937
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18938
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18939
- }),
18940
- requestOptions == null ? void 0 : requestOptions.headers
18941
- );
18942
- const _response = await fetcher({
18943
- url: url_exports.join(
18944
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18945
- `/api/public/unstable/evaluators/${encodeURIComponent(evaluatorId)}`
18946
- ),
18947
- method: "GET",
18948
- headers: _headers,
18949
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
18950
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18951
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18952
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18953
- });
18954
- if (_response.ok) {
18955
- return {
18956
- data: _response.body,
18957
- rawResponse: _response.rawResponse
18958
- };
18959
- }
18960
- if (_response.error.reason === "status-code") {
18961
- switch (_response.error.statusCode) {
18962
- case 400:
18963
- throw new unstable_exports.BadRequestError(
18964
- _response.error.body,
18965
- _response.rawResponse
18966
- );
18967
- case 401:
18968
- throw new unstable_exports.UnauthorizedError(
18969
- _response.error.body,
18970
- _response.rawResponse
18971
- );
18972
- case 403:
18973
- throw new unstable_exports.AccessDeniedError(
18974
- _response.error.body,
18975
- _response.rawResponse
18976
- );
18977
- case 404:
18978
- throw new unstable_exports.NotFoundError(
18979
- _response.error.body,
18980
- _response.rawResponse
18981
- );
18982
- case 405:
18983
- throw new unstable_exports.MethodNotAllowedError(
18984
- _response.error.body,
18985
- _response.rawResponse
18986
- );
18987
- case 429:
18988
- throw new unstable_exports.TooManyRequestsError(
18989
- _response.error.body,
18990
- _response.rawResponse
18991
- );
18992
- case 500:
18993
- throw new unstable_exports.InternalServerError(
18994
- _response.error.body,
18995
- _response.rawResponse
18996
- );
18997
- case 400:
18998
- throw new Error2(
18999
- _response.error.body,
19000
- _response.rawResponse
19001
- );
19002
- case 401:
19003
- throw new UnauthorizedError(
19004
- _response.error.body,
19005
- _response.rawResponse
19006
- );
19007
- case 403:
19008
- throw new AccessDeniedError(
19009
- _response.error.body,
19010
- _response.rawResponse
19011
- );
19012
- case 405:
19013
- throw new MethodNotAllowedError(
19014
- _response.error.body,
19015
- _response.rawResponse
19016
- );
19017
- case 404:
19018
- throw new NotFoundError(
19019
- _response.error.body,
19020
- _response.rawResponse
19021
- );
19022
- default:
19023
- throw new LangfuseAPIError({
19024
- statusCode: _response.error.statusCode,
19025
- body: _response.error.body,
19026
- rawResponse: _response.rawResponse
19027
- });
19028
- }
19029
- }
19030
- switch (_response.error.reason) {
19031
- case "non-json":
19032
- throw new LangfuseAPIError({
19033
- statusCode: _response.error.statusCode,
19034
- body: _response.error.rawBody,
19035
- rawResponse: _response.rawResponse
19036
- });
19037
- case "timeout":
19038
- throw new LangfuseAPITimeoutError(
19039
- "Timeout exceeded when calling GET /api/public/unstable/evaluators/{evaluatorId}."
19040
- );
19041
- case "unknown":
19042
- throw new LangfuseAPIError({
19043
- message: _response.error.errorMessage,
19044
- rawResponse: _response.rawResponse
19045
- });
19046
- }
19047
- }
19048
- /**
19049
- * Delete an evaluator.
19050
- *
19051
- * Important behavior:
19052
- * - This deletes the evaluator including all of its stored versions.
19053
- * - Evaluation rule assignments referencing the evaluator are also deleted.
19054
- * - Scores already produced by the evaluator are not deleted.
19055
- *
19056
- * @deprecated On Langfuse Cloud, this unstable endpoint is deprecated and will be removed on November 16, 2026. Use the stable `/api/public/v2/evaluators` API instead. Self-hosted deployments are unaffected by this date; the endpoint becomes unavailable when they upgrade to Langfuse v4.
19057
- *
19058
- * @param {string} evaluatorId - Evaluator identifier returned by the evaluator endpoints.
19059
- * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
19060
- *
19061
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
19062
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
19063
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
19064
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
19065
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
19066
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
19067
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
19068
- * @throws {@link LangfuseAPI.Error}
19069
- * @throws {@link LangfuseAPI.UnauthorizedError}
19070
- * @throws {@link LangfuseAPI.AccessDeniedError}
19071
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
19072
- * @throws {@link LangfuseAPI.NotFoundError}
19073
- *
19074
- * @example
19075
- * await client.unstable.evaluators.delete("evaluatorId")
19076
- */
19077
- delete(evaluatorId, requestOptions) {
19078
- return HttpResponsePromise.fromPromise(
19079
- this.__delete(evaluatorId, requestOptions)
19080
- );
19081
- }
19082
- async __delete(evaluatorId, requestOptions) {
19083
- var _a2, _b, _c, _d, _e, _f, _g, _h;
19084
- let _headers = mergeHeaders(
19085
- (_a2 = this._options) == null ? void 0 : _a2.headers,
19086
- mergeOnlyDefinedHeaders({
19087
- Authorization: await this._getAuthorizationHeader(),
19088
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
19089
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
19090
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
19091
- }),
19092
- requestOptions == null ? void 0 : requestOptions.headers
19093
- );
19094
- const _response = await fetcher({
19095
- url: url_exports.join(
19096
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
19097
- `/api/public/unstable/evaluators/${encodeURIComponent(evaluatorId)}`
19098
- ),
19099
- method: "DELETE",
19100
- headers: _headers,
19101
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
19102
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
19103
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
19104
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
19105
- });
19106
- if (_response.ok) {
19107
- return {
19108
- data: _response.body,
19109
- rawResponse: _response.rawResponse
19110
- };
19111
- }
19112
- if (_response.error.reason === "status-code") {
19113
- switch (_response.error.statusCode) {
19114
- case 400:
19115
- throw new unstable_exports.BadRequestError(
19116
- _response.error.body,
19117
- _response.rawResponse
19118
- );
19119
- case 401:
19120
- throw new unstable_exports.UnauthorizedError(
19121
- _response.error.body,
19122
- _response.rawResponse
19123
- );
19124
- case 403:
19125
- throw new unstable_exports.AccessDeniedError(
19126
- _response.error.body,
19127
- _response.rawResponse
19128
- );
19129
- case 404:
19130
- throw new unstable_exports.NotFoundError(
19131
- _response.error.body,
19132
- _response.rawResponse
19133
- );
19134
- case 405:
19135
- throw new unstable_exports.MethodNotAllowedError(
19136
- _response.error.body,
19137
- _response.rawResponse
19138
- );
19139
- case 429:
19140
- throw new unstable_exports.TooManyRequestsError(
19141
- _response.error.body,
19142
- _response.rawResponse
19143
- );
19144
- case 500:
19145
- throw new unstable_exports.InternalServerError(
19146
- _response.error.body,
19147
- _response.rawResponse
19148
- );
19149
- case 400:
19150
- throw new Error2(
19151
- _response.error.body,
19152
- _response.rawResponse
19153
- );
19154
- case 401:
19155
- throw new UnauthorizedError(
19156
- _response.error.body,
19157
- _response.rawResponse
19158
- );
19159
- case 403:
19160
- throw new AccessDeniedError(
19161
- _response.error.body,
19162
- _response.rawResponse
19163
- );
19164
- case 405:
19165
- throw new MethodNotAllowedError(
19166
- _response.error.body,
19167
- _response.rawResponse
19168
- );
19169
- case 404:
19170
- throw new NotFoundError(
19171
- _response.error.body,
19172
- _response.rawResponse
19173
- );
19174
- default:
19175
- throw new LangfuseAPIError({
19176
- statusCode: _response.error.statusCode,
19177
- body: _response.error.body,
19178
- rawResponse: _response.rawResponse
19179
- });
19180
- }
19181
- }
19182
- switch (_response.error.reason) {
19183
- case "non-json":
19184
- throw new LangfuseAPIError({
19185
- statusCode: _response.error.statusCode,
19186
- body: _response.error.rawBody,
19187
- rawResponse: _response.rawResponse
19188
- });
19189
- case "timeout":
19190
- throw new LangfuseAPITimeoutError(
19191
- "Timeout exceeded when calling DELETE /api/public/unstable/evaluators/{evaluatorId}."
19192
- );
19193
- case "unknown":
19194
- throw new LangfuseAPIError({
19195
- message: _response.error.errorMessage,
19196
- rawResponse: _response.rawResponse
19197
- });
19198
- }
19199
- }
19200
- async _getAuthorizationHeader() {
19201
- const username = await Supplier.get(this._options.username);
19202
- const password = await Supplier.get(this._options.password);
19203
- if (username != null && password != null) {
19204
- return BasicAuth.toAuthorizationHeader({
19205
- username,
19206
- password
19207
- });
19208
- }
19209
- return void 0;
19210
- }
19211
- };
19212
-
19213
- // src/api/api/resources/unstable/client/Client.ts
19214
- var Unstable = class {
19215
- constructor(_options) {
19216
- this._options = _options;
19217
- }
19218
- get dashboardWidgets() {
19219
- var _a2;
19220
- return (_a2 = this._dashboardWidgets) != null ? _a2 : this._dashboardWidgets = new DashboardWidgets(this._options);
17422
+ get dashboardWidgets() {
17423
+ var _a2;
17424
+ return (_a2 = this._dashboardWidgets) != null ? _a2 : this._dashboardWidgets = new DashboardWidgets(this._options);
19221
17425
  }
19222
17426
  get dashboards() {
19223
17427
  var _a2;
19224
17428
  return (_a2 = this._dashboards) != null ? _a2 : this._dashboards = new Dashboards(this._options);
19225
17429
  }
19226
- get evaluationRules() {
19227
- var _a2;
19228
- return (_a2 = this._evaluationRules) != null ? _a2 : this._evaluationRules = new EvaluationRules2(this._options);
19229
- }
19230
- get evaluators() {
19231
- var _a2;
19232
- return (_a2 = this._evaluators) != null ? _a2 : this._evaluators = new Evaluators2(this._options);
19233
- }
19234
17430
  };
19235
17431
 
19236
17432
  // src/api/Client.ts
@@ -20302,6 +18498,7 @@ export {
20302
18498
  EvaluationRuleOptionsFilterOperator,
20303
18499
  EvaluationRuleStringFilterOperator,
20304
18500
  EvaluationUnauthorizedError,
18501
+ EvaluatorChatMessageRole,
20305
18502
  EvaluatorOutputScoreType,
20306
18503
  EvaluatorStatus,
20307
18504
  EvaluatorType,