@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.cjs CHANGED
@@ -52,6 +52,7 @@ __export(index_exports, {
52
52
  EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator,
53
53
  EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator,
54
54
  EvaluationUnauthorizedError: () => EvaluationUnauthorizedError,
55
+ EvaluatorChatMessageRole: () => EvaluatorChatMessageRole,
55
56
  EvaluatorOutputScoreType: () => EvaluatorOutputScoreType,
56
57
  EvaluatorStatus: () => EvaluatorStatus,
57
58
  EvaluatorType: () => EvaluatorType,
@@ -424,7 +425,7 @@ var resetGlobalLogger = () => {
424
425
  // package.json
425
426
  var package_default = {
426
427
  name: "@langfuse/core",
427
- version: "5.11.0",
428
+ version: "5.11.1",
428
429
  description: "Core functions and utilities for Langfuse packages",
429
430
  type: "module",
430
431
  sideEffects: false,
@@ -1099,9 +1100,17 @@ var evaluationRules_exports = {};
1099
1100
  // src/api/api/resources/evaluators/index.ts
1100
1101
  var evaluators_exports = {};
1101
1102
  __export(evaluators_exports, {
1103
+ EvaluatorChatMessageRole: () => EvaluatorChatMessageRole,
1102
1104
  EvaluatorStatus: () => EvaluatorStatus
1103
1105
  });
1104
1106
 
1107
+ // src/api/api/resources/evaluators/types/EvaluatorChatMessageRole.ts
1108
+ var EvaluatorChatMessageRole = {
1109
+ System: "system",
1110
+ User: "user",
1111
+ Assistant: "assistant"
1112
+ };
1113
+
1105
1114
  // src/api/api/resources/evaluators/types/EvaluatorStatus.ts
1106
1115
  var EvaluatorStatus = {
1107
1116
  Active: "active",
@@ -1383,145 +1392,23 @@ var unstable_exports = {};
1383
1392
  __export(unstable_exports, {
1384
1393
  AccessDeniedError: () => AccessDeniedError2,
1385
1394
  BadRequestError: () => BadRequestError2,
1386
- CodeEvaluatorSourceCodeLanguage: () => CodeEvaluatorSourceCodeLanguage2,
1387
1395
  ConflictError: () => ConflictError2,
1388
1396
  DashboardWidgetChartType: () => DashboardWidgetChartType,
1389
1397
  DashboardWidgetMetricAggregation: () => DashboardWidgetMetricAggregation,
1390
1398
  DashboardWidgetSortOrder: () => DashboardWidgetSortOrder,
1391
1399
  DashboardWidgetView: () => DashboardWidgetView,
1392
1400
  DashboardWidgetViewWithLegacy: () => DashboardWidgetViewWithLegacy,
1393
- EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator2,
1394
- EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator2,
1395
- EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator2,
1396
- EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator2,
1397
- EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator2,
1398
- EvaluationRuleStatus: () => EvaluationRuleStatus,
1399
- EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator2,
1400
- EvaluationRuleTarget: () => EvaluationRuleTarget,
1401
- EvaluationRuleTimeScope: () => EvaluationRuleTimeScope,
1402
- EvaluatorOutputDataType: () => EvaluatorOutputDataType,
1403
- EvaluatorType: () => EvaluatorType2,
1404
1401
  InternalServerError: () => InternalServerError2,
1405
- LegacyEvaluationObject: () => LegacyEvaluationObject2,
1406
- LegacyEvaluationRuleTarget: () => LegacyEvaluationRuleTarget,
1407
- LlmAsJudgeEvaluatorType: () => LlmAsJudgeEvaluatorType,
1408
1402
  MethodNotAllowedError: () => MethodNotAllowedError2,
1409
1403
  NotFoundError: () => NotFoundError2,
1410
- PromptVariableMappingSource: () => PromptVariableMappingSource2,
1411
1404
  PublicApiErrorCode: () => PublicApiErrorCode2,
1412
1405
  TooManyRequestsError: () => TooManyRequestsError2,
1413
1406
  UnauthorizedError: () => UnauthorizedError2,
1414
- UnprocessableContentError: () => UnprocessableContentError,
1415
- commons: () => commons_exports2,
1416
1407
  dashboardWidgets: () => dashboardWidgets_exports,
1417
1408
  dashboards: () => dashboards_exports,
1418
- errors: () => errors_exports2,
1419
- evaluationRules: () => evaluationRules_exports2,
1420
- evaluators: () => evaluators_exports2
1421
- });
1422
-
1423
- // src/api/api/resources/unstable/resources/commons/index.ts
1424
- var commons_exports2 = {};
1425
- __export(commons_exports2, {
1426
- CodeEvaluatorSourceCodeLanguage: () => CodeEvaluatorSourceCodeLanguage2,
1427
- EvaluationRuleArrayOptionsFilterOperator: () => EvaluationRuleArrayOptionsFilterOperator2,
1428
- EvaluationRuleBooleanFilterOperator: () => EvaluationRuleBooleanFilterOperator2,
1429
- EvaluationRuleNullFilterOperator: () => EvaluationRuleNullFilterOperator2,
1430
- EvaluationRuleNumberFilterOperator: () => EvaluationRuleNumberFilterOperator2,
1431
- EvaluationRuleOptionsFilterOperator: () => EvaluationRuleOptionsFilterOperator2,
1432
- EvaluationRuleStatus: () => EvaluationRuleStatus,
1433
- EvaluationRuleStringFilterOperator: () => EvaluationRuleStringFilterOperator2,
1434
- EvaluationRuleTarget: () => EvaluationRuleTarget,
1435
- EvaluatorOutputDataType: () => EvaluatorOutputDataType,
1436
- EvaluatorType: () => EvaluatorType2,
1437
- PromptVariableMappingSource: () => PromptVariableMappingSource2
1409
+ errors: () => errors_exports2
1438
1410
  });
1439
1411
 
1440
- // src/api/api/resources/unstable/resources/commons/types/EvaluatorType.ts
1441
- var EvaluatorType2 = {
1442
- LlmAsJudge: "llm_as_judge",
1443
- Code: "code"
1444
- };
1445
-
1446
- // src/api/api/resources/unstable/resources/commons/types/CodeEvaluatorSourceCodeLanguage.ts
1447
- var CodeEvaluatorSourceCodeLanguage2 = {
1448
- Python: "PYTHON",
1449
- Typescript: "TYPESCRIPT"
1450
- };
1451
-
1452
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleTarget.ts
1453
- var EvaluationRuleTarget = {
1454
- Observation: "observation",
1455
- Experiment: "experiment"
1456
- };
1457
-
1458
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStatus.ts
1459
- var EvaluationRuleStatus = {
1460
- Active: "active",
1461
- Inactive: "inactive",
1462
- Paused: "paused"
1463
- };
1464
-
1465
- // src/api/api/resources/unstable/resources/commons/types/PromptVariableMappingSource.ts
1466
- var PromptVariableMappingSource2 = {
1467
- Input: "input",
1468
- Output: "output",
1469
- Metadata: "metadata",
1470
- ToolCalls: "tool_calls",
1471
- ExpectedOutput: "expected_output",
1472
- ExperimentItemMetadata: "experiment_item_metadata"
1473
- };
1474
-
1475
- // src/api/api/resources/unstable/resources/commons/types/EvaluatorOutputDataType.ts
1476
- var EvaluatorOutputDataType = {
1477
- Numeric: "NUMERIC",
1478
- Boolean: "BOOLEAN",
1479
- Categorical: "CATEGORICAL"
1480
- };
1481
-
1482
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleStringFilterOperator.ts
1483
- var EvaluationRuleStringFilterOperator2 = {
1484
- Equals: "=",
1485
- Contains: "contains",
1486
- DoesNotContain: "does not contain",
1487
- StartsWith: "starts with",
1488
- EndsWith: "ends with"
1489
- };
1490
-
1491
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNumberFilterOperator.ts
1492
- var EvaluationRuleNumberFilterOperator2 = {
1493
- Equals: "=",
1494
- GreaterThan: ">",
1495
- LessThan: "<",
1496
- GreaterThanOrEqual: ">=",
1497
- LessThanOrEqual: "<="
1498
- };
1499
-
1500
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleOptionsFilterOperator.ts
1501
- var EvaluationRuleOptionsFilterOperator2 = {
1502
- AnyOf: "any of",
1503
- NoneOf: "none of"
1504
- };
1505
-
1506
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleArrayOptionsFilterOperator.ts
1507
- var EvaluationRuleArrayOptionsFilterOperator2 = {
1508
- AnyOf: "any of",
1509
- NoneOf: "none of",
1510
- AllOf: "all of"
1511
- };
1512
-
1513
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleBooleanFilterOperator.ts
1514
- var EvaluationRuleBooleanFilterOperator2 = {
1515
- Equals: "=",
1516
- NotEquals: "<>"
1517
- };
1518
-
1519
- // src/api/api/resources/unstable/resources/commons/types/EvaluationRuleNullFilterOperator.ts
1520
- var EvaluationRuleNullFilterOperator2 = {
1521
- IsNull: "is null",
1522
- IsNotNull: "is not null"
1523
- };
1524
-
1525
1412
  // src/api/api/resources/unstable/resources/dashboardWidgets/index.ts
1526
1413
  var dashboardWidgets_exports = {};
1527
1414
  __export(dashboardWidgets_exports, {
@@ -1598,8 +1485,7 @@ __export(errors_exports2, {
1598
1485
  NotFoundError: () => NotFoundError2,
1599
1486
  PublicApiErrorCode: () => PublicApiErrorCode2,
1600
1487
  TooManyRequestsError: () => TooManyRequestsError2,
1601
- UnauthorizedError: () => UnauthorizedError2,
1602
- UnprocessableContentError: () => UnprocessableContentError
1488
+ UnauthorizedError: () => UnauthorizedError2
1603
1489
  });
1604
1490
 
1605
1491
  // src/api/api/resources/unstable/resources/errors/types/PublicApiErrorCode.ts
@@ -1609,16 +1495,8 @@ var PublicApiErrorCode2 = {
1609
1495
  InvalidRequest: "invalid_request",
1610
1496
  InvalidQuery: "invalid_query",
1611
1497
  InvalidBody: "invalid_body",
1612
- InvalidFilterValue: "invalid_filter_value",
1613
- InvalidJsonPath: "invalid_json_path",
1614
- InvalidVariableMapping: "invalid_variable_mapping",
1615
- MissingVariableMapping: "missing_variable_mapping",
1616
- DuplicateVariableMapping: "duplicate_variable_mapping",
1617
1498
  ResourceNotFound: "resource_not_found",
1618
- NameConflict: "name_conflict",
1619
- EvaluatorPreflightFailed: "evaluator_preflight_failed",
1620
1499
  Conflict: "conflict",
1621
- UnprocessableContent: "unprocessable_content",
1622
1500
  RateLimited: "rate_limited",
1623
1501
  MethodNotAllowed: "method_not_allowed",
1624
1502
  InternalError: "internal_error"
@@ -1702,19 +1580,6 @@ var ConflictError2 = class _ConflictError extends LangfuseAPIError {
1702
1580
  }
1703
1581
  };
1704
1582
 
1705
- // src/api/api/resources/unstable/resources/errors/errors/UnprocessableContentError.ts
1706
- var UnprocessableContentError = class _UnprocessableContentError extends LangfuseAPIError {
1707
- constructor(body, rawResponse) {
1708
- super({
1709
- message: "UnprocessableContentError",
1710
- statusCode: 422,
1711
- body,
1712
- rawResponse
1713
- });
1714
- Object.setPrototypeOf(this, _UnprocessableContentError.prototype);
1715
- }
1716
- };
1717
-
1718
1583
  // src/api/api/resources/unstable/resources/errors/errors/TooManyRequestsError.ts
1719
1584
  var TooManyRequestsError2 = class _TooManyRequestsError extends LangfuseAPIError {
1720
1585
  constructor(body, rawResponse) {
@@ -1741,51 +1606,6 @@ var InternalServerError2 = class _InternalServerError extends LangfuseAPIError {
1741
1606
  }
1742
1607
  };
1743
1608
 
1744
- // src/api/api/resources/unstable/resources/evaluationRules/index.ts
1745
- var evaluationRules_exports2 = {};
1746
- __export(evaluationRules_exports2, {
1747
- EvaluationRuleTimeScope: () => EvaluationRuleTimeScope,
1748
- LegacyEvaluationObject: () => LegacyEvaluationObject2,
1749
- LegacyEvaluationRuleTarget: () => LegacyEvaluationRuleTarget,
1750
- LlmAsJudgeEvaluatorType: () => LlmAsJudgeEvaluatorType
1751
- });
1752
-
1753
- // src/api/api/resources/unstable/resources/evaluationRules/types/LlmAsJudgeEvaluatorType.ts
1754
- var LlmAsJudgeEvaluatorType = {
1755
- LlmAsJudge: "llm_as_judge"
1756
- };
1757
-
1758
- // src/api/api/resources/unstable/resources/evaluationRules/types/EvaluationRuleTimeScope.ts
1759
- var EvaluationRuleTimeScope = {
1760
- New: "NEW",
1761
- Existing: "EXISTING"
1762
- };
1763
-
1764
- // src/api/api/resources/unstable/resources/evaluationRules/types/LegacyEvaluationRuleTarget.ts
1765
- var LegacyEvaluationRuleTarget = {
1766
- Trace: "trace",
1767
- Dataset: "dataset"
1768
- };
1769
-
1770
- // src/api/api/resources/unstable/resources/evaluationRules/types/LegacyEvaluationObject.ts
1771
- var LegacyEvaluationObject2 = {
1772
- Trace: "trace",
1773
- Span: "span",
1774
- Generation: "generation",
1775
- Event: "event",
1776
- Agent: "agent",
1777
- Tool: "tool",
1778
- Chain: "chain",
1779
- Retriever: "retriever",
1780
- Evaluator: "evaluator",
1781
- Embedding: "embedding",
1782
- Guardrail: "guardrail",
1783
- DatasetItem: "dataset_item"
1784
- };
1785
-
1786
- // src/api/api/resources/unstable/resources/evaluators/index.ts
1787
- var evaluators_exports2 = {};
1788
-
1789
1609
  // src/api/api/resources/utils/index.ts
1790
1610
  var utils_exports = {};
1791
1611
  __export(utils_exports, {
@@ -10863,7 +10683,7 @@ var Observations = class {
10863
10683
  * - `time` - completionStartTime, createdAt, updatedAt
10864
10684
  * - `io` - input, output
10865
10685
  * - `metadata` - metadata (truncated to 200 chars by default, use `expandMetadata` to get full values)
10866
- * - `model` - providedModelName, internalModelId, modelParameters
10686
+ * - `model` - model, internalModelId, modelParameters
10867
10687
  * - `usage` - usageDetails, costDetails, totalCost, usagePricingTierName
10868
10688
  * - `prompt` - promptId, promptName, promptVersion
10869
10689
  * - `metrics` - latency, timeToFirstToken
@@ -17743,1642 +17563,19 @@ var Dashboards = class {
17743
17563
  }
17744
17564
  };
17745
17565
 
17746
- // src/api/api/resources/unstable/resources/evaluationRules/client/Client.ts
17747
- var EvaluationRules2 = class {
17566
+ // src/api/api/resources/unstable/client/Client.ts
17567
+ var Unstable = class {
17748
17568
  constructor(_options) {
17749
17569
  this._options = _options;
17750
17570
  }
17751
- /**
17752
- * Create an evaluation rule.
17753
- *
17754
- * An evaluation rule defines **what** incoming data should be evaluated and **how prompt variables should be populated** from that data.
17755
- *
17756
- * Use this resource after choosing an evaluator from the evaluator endpoints.
17757
- *
17758
- * Key rules:
17759
- * - `name` must be unique within the project for public evaluation rules
17760
- * - `target` must be `observation` or `experiment`
17761
- * - provide either the compatibility `evaluator` field or the new `evaluators` array, never both
17762
- * - each evaluator `name` + `type` must identify an existing evaluator family returned by the evaluator endpoints
17763
- * - Langfuse resolves that family to its latest version before saving the evaluation rule
17764
- * - for `target=experiment`, use dataset `id` values from `GET /api/public/v2/datasets` when filtering by `datasetId`
17765
- * - an omitted LLM-as-judge assignment mapping inherits the evaluator version's default mapping
17766
- * - the effective mapping must map every evaluator prompt variable exactly once
17767
- * - for `code` evaluators, Langfuse uses the fixed code runtime mapping; omit `mapping` in create and update requests
17768
- * - for user-provided `llm_as_judge` mappings, `expected_output` and `experiment_item_metadata` are only valid for `target=experiment`
17769
- * - if `enabled=true`, Langfuse validates that the referenced evaluator can currently run
17770
- * - 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)
17771
- *
17772
- * If an evaluation rule with the same `name` already exists in the project, the API returns `409`.
17773
- * In that case, update the existing resource with `PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}` instead of creating a second one.
17774
- *
17775
- * If enabling this resource would exceed the 500-active limit, the API also returns `409`.
17776
- * In that case, disable or pause another active evaluation rule before enabling a new one.
17777
- *
17778
- * Current scope:
17779
- * - evaluation rules are live-ingestion rules only
17780
- * - they do not trigger historical backfills
17781
- *
17782
- * Recovery guidance:
17783
- * - `400 invalid_filter_value`: fix the filter `column` or `value` using `details.column`, `details.invalidValues`, and `details.allowedValues`
17784
- * - `400 invalid_filter_value` with `details.column=datasetId`: call `GET /api/public/v2/datasets`, then retry with dataset `id` values from that response
17785
- * - `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`
17786
- * - `400 duplicate_variable_mapping`: remove repeated mappings for the same variable
17787
- * - `400 invalid_variable_mapping`: for `llm_as_judge`, switch to a valid `source` for the selected `target`, or fix the variable name
17788
- * - `400 invalid_json_path`: remove or correct the `jsonPath`
17789
- * - `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.
17790
- *
17791
- * @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.
17792
- *
17793
- * @param {LangfuseAPI.unstable.CreateEvaluationRuleRequest} request
17794
- * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
17795
- *
17796
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
17797
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
17798
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
17799
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
17800
- * @throws {@link LangfuseAPI.unstable.ConflictError}
17801
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
17802
- * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
17803
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
17804
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
17805
- * @throws {@link LangfuseAPI.Error}
17806
- * @throws {@link LangfuseAPI.UnauthorizedError}
17807
- * @throws {@link LangfuseAPI.AccessDeniedError}
17808
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
17809
- * @throws {@link LangfuseAPI.NotFoundError}
17810
- *
17811
- * @example
17812
- * await client.unstable.evaluationRules.create({
17813
- * name: "answer-correctness-live",
17814
- * evaluator: {
17815
- * name: "answer-correctness",
17816
- * type: "llm_as_judge"
17817
- * },
17818
- * target: "observation",
17819
- * enabled: true,
17820
- * sampling: 1,
17821
- * filter: [{
17822
- * type: "stringOptions",
17823
- * column: "type",
17824
- * operator: "any of",
17825
- * value: ["GENERATION"]
17826
- * }],
17827
- * mapping: [{
17828
- * variable: "input",
17829
- * source: "input"
17830
- * }, {
17831
- * variable: "output",
17832
- * source: "output"
17833
- * }]
17834
- * })
17835
- *
17836
- * @example
17837
- * await client.unstable.evaluationRules.create({
17838
- * name: "toxicity-code-live",
17839
- * evaluator: {
17840
- * name: "toxicity-detector",
17841
- * type: "code"
17842
- * },
17843
- * target: "observation",
17844
- * enabled: true,
17845
- * sampling: 1,
17846
- * filter: [{
17847
- * type: "stringOptions",
17848
- * column: "type",
17849
- * operator: "any of",
17850
- * value: ["GENERATION"]
17851
- * }]
17852
- * })
17853
- *
17854
- * @example
17855
- * await client.unstable.evaluationRules.create({
17856
- * name: "experiment-expected-output-match",
17857
- * evaluator: {
17858
- * name: "expected-output-match",
17859
- * type: "llm_as_judge"
17860
- * },
17861
- * target: "experiment",
17862
- * enabled: true,
17863
- * sampling: 0.5,
17864
- * filter: [{
17865
- * type: "stringOptions",
17866
- * column: "datasetId",
17867
- * operator: "any of",
17868
- * value: ["550e8400-e29b-41d4-a716-446655440000"]
17869
- * }],
17870
- * mapping: [{
17871
- * variable: "output",
17872
- * source: "output"
17873
- * }, {
17874
- * variable: "expected_output",
17875
- * source: "expected_output"
17876
- * }]
17877
- * })
17878
- */
17879
- create(request, requestOptions) {
17880
- return HttpResponsePromise.fromPromise(
17881
- this.__create(request, requestOptions)
17882
- );
17883
- }
17884
- async __create(request, requestOptions) {
17885
- var _a2, _b, _c, _d, _e, _f, _g, _h;
17886
- let _headers = mergeHeaders(
17887
- (_a2 = this._options) == null ? void 0 : _a2.headers,
17888
- mergeOnlyDefinedHeaders({
17889
- Authorization: await this._getAuthorizationHeader(),
17890
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
17891
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
17892
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
17893
- }),
17894
- requestOptions == null ? void 0 : requestOptions.headers
17895
- );
17896
- const _response = await fetcher({
17897
- url: url_exports.join(
17898
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
17899
- "/api/public/unstable/evaluation-rules"
17900
- ),
17901
- method: "POST",
17902
- headers: _headers,
17903
- contentType: "application/json",
17904
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
17905
- requestType: "json",
17906
- body: request,
17907
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
17908
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
17909
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
17910
- });
17911
- if (_response.ok) {
17912
- return {
17913
- data: _response.body,
17914
- rawResponse: _response.rawResponse
17915
- };
17916
- }
17917
- if (_response.error.reason === "status-code") {
17918
- switch (_response.error.statusCode) {
17919
- case 400:
17920
- throw new unstable_exports.BadRequestError(
17921
- _response.error.body,
17922
- _response.rawResponse
17923
- );
17924
- case 401:
17925
- throw new unstable_exports.UnauthorizedError(
17926
- _response.error.body,
17927
- _response.rawResponse
17928
- );
17929
- case 403:
17930
- throw new unstable_exports.AccessDeniedError(
17931
- _response.error.body,
17932
- _response.rawResponse
17933
- );
17934
- case 404:
17935
- throw new unstable_exports.NotFoundError(
17936
- _response.error.body,
17937
- _response.rawResponse
17938
- );
17939
- case 409:
17940
- throw new unstable_exports.ConflictError(
17941
- _response.error.body,
17942
- _response.rawResponse
17943
- );
17944
- case 405:
17945
- throw new unstable_exports.MethodNotAllowedError(
17946
- _response.error.body,
17947
- _response.rawResponse
17948
- );
17949
- case 422:
17950
- throw new unstable_exports.UnprocessableContentError(
17951
- _response.error.body,
17952
- _response.rawResponse
17953
- );
17954
- case 429:
17955
- throw new unstable_exports.TooManyRequestsError(
17956
- _response.error.body,
17957
- _response.rawResponse
17958
- );
17959
- case 500:
17960
- throw new unstable_exports.InternalServerError(
17961
- _response.error.body,
17962
- _response.rawResponse
17963
- );
17964
- case 400:
17965
- throw new Error2(
17966
- _response.error.body,
17967
- _response.rawResponse
17968
- );
17969
- case 401:
17970
- throw new UnauthorizedError(
17971
- _response.error.body,
17972
- _response.rawResponse
17973
- );
17974
- case 403:
17975
- throw new AccessDeniedError(
17976
- _response.error.body,
17977
- _response.rawResponse
17978
- );
17979
- case 405:
17980
- throw new MethodNotAllowedError(
17981
- _response.error.body,
17982
- _response.rawResponse
17983
- );
17984
- case 404:
17985
- throw new NotFoundError(
17986
- _response.error.body,
17987
- _response.rawResponse
17988
- );
17989
- default:
17990
- throw new LangfuseAPIError({
17991
- statusCode: _response.error.statusCode,
17992
- body: _response.error.body,
17993
- rawResponse: _response.rawResponse
17994
- });
17995
- }
17996
- }
17997
- switch (_response.error.reason) {
17998
- case "non-json":
17999
- throw new LangfuseAPIError({
18000
- statusCode: _response.error.statusCode,
18001
- body: _response.error.rawBody,
18002
- rawResponse: _response.rawResponse
18003
- });
18004
- case "timeout":
18005
- throw new LangfuseAPITimeoutError(
18006
- "Timeout exceeded when calling POST /api/public/unstable/evaluation-rules."
18007
- );
18008
- case "unknown":
18009
- throw new LangfuseAPIError({
18010
- message: _response.error.errorMessage,
18011
- rawResponse: _response.rawResponse
18012
- });
18013
- }
18014
- }
18015
- /**
18016
- * List evaluation rules in the authenticated project.
18017
- *
18018
- * 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.
18019
- *
18020
- * @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.
18021
- *
18022
- * @param {LangfuseAPI.unstable.ListEvaluationRulesRequest} request
18023
- * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
18024
- *
18025
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18026
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18027
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18028
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18029
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18030
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18031
- * @throws {@link LangfuseAPI.Error}
18032
- * @throws {@link LangfuseAPI.UnauthorizedError}
18033
- * @throws {@link LangfuseAPI.AccessDeniedError}
18034
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18035
- * @throws {@link LangfuseAPI.NotFoundError}
18036
- *
18037
- * @example
18038
- * await client.unstable.evaluationRules.list()
18039
- */
18040
- list(request = {}, requestOptions) {
18041
- return HttpResponsePromise.fromPromise(
18042
- this.__list(request, requestOptions)
18043
- );
18044
- }
18045
- async __list(request = {}, requestOptions) {
18046
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18047
- const { page, limit } = request;
18048
- const _queryParams = {};
18049
- if (page != null) {
18050
- _queryParams["page"] = page.toString();
18051
- }
18052
- if (limit != null) {
18053
- _queryParams["limit"] = limit.toString();
18054
- }
18055
- let _headers = mergeHeaders(
18056
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18057
- mergeOnlyDefinedHeaders({
18058
- Authorization: await this._getAuthorizationHeader(),
18059
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18060
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18061
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18062
- }),
18063
- requestOptions == null ? void 0 : requestOptions.headers
18064
- );
18065
- const _response = await fetcher({
18066
- url: url_exports.join(
18067
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18068
- "/api/public/unstable/evaluation-rules"
18069
- ),
18070
- method: "GET",
18071
- headers: _headers,
18072
- queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
18073
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18074
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18075
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18076
- });
18077
- if (_response.ok) {
18078
- return {
18079
- data: _response.body,
18080
- rawResponse: _response.rawResponse
18081
- };
18082
- }
18083
- if (_response.error.reason === "status-code") {
18084
- switch (_response.error.statusCode) {
18085
- case 400:
18086
- throw new unstable_exports.BadRequestError(
18087
- _response.error.body,
18088
- _response.rawResponse
18089
- );
18090
- case 401:
18091
- throw new unstable_exports.UnauthorizedError(
18092
- _response.error.body,
18093
- _response.rawResponse
18094
- );
18095
- case 403:
18096
- throw new unstable_exports.AccessDeniedError(
18097
- _response.error.body,
18098
- _response.rawResponse
18099
- );
18100
- case 405:
18101
- throw new unstable_exports.MethodNotAllowedError(
18102
- _response.error.body,
18103
- _response.rawResponse
18104
- );
18105
- case 429:
18106
- throw new unstable_exports.TooManyRequestsError(
18107
- _response.error.body,
18108
- _response.rawResponse
18109
- );
18110
- case 500:
18111
- throw new unstable_exports.InternalServerError(
18112
- _response.error.body,
18113
- _response.rawResponse
18114
- );
18115
- case 400:
18116
- throw new Error2(
18117
- _response.error.body,
18118
- _response.rawResponse
18119
- );
18120
- case 401:
18121
- throw new UnauthorizedError(
18122
- _response.error.body,
18123
- _response.rawResponse
18124
- );
18125
- case 403:
18126
- throw new AccessDeniedError(
18127
- _response.error.body,
18128
- _response.rawResponse
18129
- );
18130
- case 405:
18131
- throw new MethodNotAllowedError(
18132
- _response.error.body,
18133
- _response.rawResponse
18134
- );
18135
- case 404:
18136
- throw new NotFoundError(
18137
- _response.error.body,
18138
- _response.rawResponse
18139
- );
18140
- default:
18141
- throw new LangfuseAPIError({
18142
- statusCode: _response.error.statusCode,
18143
- body: _response.error.body,
18144
- rawResponse: _response.rawResponse
18145
- });
18146
- }
18147
- }
18148
- switch (_response.error.reason) {
18149
- case "non-json":
18150
- throw new LangfuseAPIError({
18151
- statusCode: _response.error.statusCode,
18152
- body: _response.error.rawBody,
18153
- rawResponse: _response.rawResponse
18154
- });
18155
- case "timeout":
18156
- throw new LangfuseAPITimeoutError(
18157
- "Timeout exceeded when calling GET /api/public/unstable/evaluation-rules."
18158
- );
18159
- case "unknown":
18160
- throw new LangfuseAPIError({
18161
- message: _response.error.errorMessage,
18162
- rawResponse: _response.rawResponse
18163
- });
18164
- }
18165
- }
18166
- /**
18167
- * Get one evaluation rule by its identifier.
18168
- *
18169
- * 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.
18170
- *
18171
- * @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.
18172
- *
18173
- * @param {string} evaluationRuleId - Evaluation rule identifier returned by the evaluation rule endpoints.
18174
- * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
18175
- *
18176
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18177
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18178
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18179
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
18180
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18181
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18182
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18183
- * @throws {@link LangfuseAPI.Error}
18184
- * @throws {@link LangfuseAPI.UnauthorizedError}
18185
- * @throws {@link LangfuseAPI.AccessDeniedError}
18186
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18187
- * @throws {@link LangfuseAPI.NotFoundError}
18188
- *
18189
- * @example
18190
- * await client.unstable.evaluationRules.get("evaluationRuleId")
18191
- */
18192
- get(evaluationRuleId, requestOptions) {
18193
- return HttpResponsePromise.fromPromise(
18194
- this.__get(evaluationRuleId, requestOptions)
18195
- );
18196
- }
18197
- async __get(evaluationRuleId, requestOptions) {
18198
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18199
- let _headers = mergeHeaders(
18200
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18201
- mergeOnlyDefinedHeaders({
18202
- Authorization: await this._getAuthorizationHeader(),
18203
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18204
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18205
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18206
- }),
18207
- requestOptions == null ? void 0 : requestOptions.headers
18208
- );
18209
- const _response = await fetcher({
18210
- url: url_exports.join(
18211
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18212
- `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
18213
- ),
18214
- method: "GET",
18215
- headers: _headers,
18216
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
18217
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18218
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18219
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18220
- });
18221
- if (_response.ok) {
18222
- return {
18223
- data: _response.body,
18224
- rawResponse: _response.rawResponse
18225
- };
18226
- }
18227
- if (_response.error.reason === "status-code") {
18228
- switch (_response.error.statusCode) {
18229
- case 400:
18230
- throw new unstable_exports.BadRequestError(
18231
- _response.error.body,
18232
- _response.rawResponse
18233
- );
18234
- case 401:
18235
- throw new unstable_exports.UnauthorizedError(
18236
- _response.error.body,
18237
- _response.rawResponse
18238
- );
18239
- case 403:
18240
- throw new unstable_exports.AccessDeniedError(
18241
- _response.error.body,
18242
- _response.rawResponse
18243
- );
18244
- case 404:
18245
- throw new unstable_exports.NotFoundError(
18246
- _response.error.body,
18247
- _response.rawResponse
18248
- );
18249
- case 405:
18250
- throw new unstable_exports.MethodNotAllowedError(
18251
- _response.error.body,
18252
- _response.rawResponse
18253
- );
18254
- case 429:
18255
- throw new unstable_exports.TooManyRequestsError(
18256
- _response.error.body,
18257
- _response.rawResponse
18258
- );
18259
- case 500:
18260
- throw new unstable_exports.InternalServerError(
18261
- _response.error.body,
18262
- _response.rawResponse
18263
- );
18264
- case 400:
18265
- throw new Error2(
18266
- _response.error.body,
18267
- _response.rawResponse
18268
- );
18269
- case 401:
18270
- throw new UnauthorizedError(
18271
- _response.error.body,
18272
- _response.rawResponse
18273
- );
18274
- case 403:
18275
- throw new AccessDeniedError(
18276
- _response.error.body,
18277
- _response.rawResponse
18278
- );
18279
- case 405:
18280
- throw new MethodNotAllowedError(
18281
- _response.error.body,
18282
- _response.rawResponse
18283
- );
18284
- case 404:
18285
- throw new NotFoundError(
18286
- _response.error.body,
18287
- _response.rawResponse
18288
- );
18289
- default:
18290
- throw new LangfuseAPIError({
18291
- statusCode: _response.error.statusCode,
18292
- body: _response.error.body,
18293
- rawResponse: _response.rawResponse
18294
- });
18295
- }
18296
- }
18297
- switch (_response.error.reason) {
18298
- case "non-json":
18299
- throw new LangfuseAPIError({
18300
- statusCode: _response.error.statusCode,
18301
- body: _response.error.rawBody,
18302
- rawResponse: _response.rawResponse
18303
- });
18304
- case "timeout":
18305
- throw new LangfuseAPITimeoutError(
18306
- "Timeout exceeded when calling GET /api/public/unstable/evaluation-rules/{evaluationRuleId}."
18307
- );
18308
- case "unknown":
18309
- throw new LangfuseAPIError({
18310
- message: _response.error.errorMessage,
18311
- rawResponse: _response.rawResponse
18312
- });
18313
- }
18314
- }
18315
- /**
18316
- * Update an evaluation rule.
18317
- *
18318
- * Typical uses:
18319
- * - enable or disable live execution
18320
- * - switch to another evaluator
18321
- * - adjust sampling
18322
- * - change filters
18323
- * - update LLM-as-judge variable mappings
18324
- *
18325
- * Important behavior:
18326
- * - provide only the fields you want to change
18327
- * - if you provide `evaluator`, Langfuse resolves that evaluator family to its latest version before saving
18328
- * - changing `target`, `filter`, or an LLM-as-judge `mapping` must still produce a valid target-specific configuration
18329
- * - 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
18330
- * - for `code` evaluator rules, omit `mapping`; Langfuse stores the fixed code runtime mapping automatically
18331
- * - if the resulting config is enabled, Langfuse re-validates that the selected evaluator can run
18332
- * - 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`
18333
- *
18334
- * Recovery guidance:
18335
- * - 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`
18336
- * - if the update fails with `invalid_filter_value` after changing `target`, resend the request with a target-compatible `filter`
18337
- *
18338
- * @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.
18339
- *
18340
- * @param {string} evaluationRuleId - Evaluation rule identifier.
18341
- * @param {LangfuseAPI.unstable.UpdateEvaluationRuleRequest} request
18342
- * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
18343
- *
18344
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18345
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18346
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18347
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
18348
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18349
- * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
18350
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18351
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18352
- * @throws {@link LangfuseAPI.Error}
18353
- * @throws {@link LangfuseAPI.UnauthorizedError}
18354
- * @throws {@link LangfuseAPI.AccessDeniedError}
18355
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18356
- * @throws {@link LangfuseAPI.NotFoundError}
18357
- *
18358
- * @example
18359
- * await client.unstable.evaluationRules.update("evaluationRuleId", {
18360
- * name: undefined,
18361
- * evaluators: undefined,
18362
- * evaluator: undefined,
18363
- * target: undefined,
18364
- * enabled: undefined,
18365
- * sampling: undefined,
18366
- * filter: undefined,
18367
- * mapping: undefined
18368
- * })
18369
- */
18370
- update(evaluationRuleId, request, requestOptions) {
18371
- return HttpResponsePromise.fromPromise(
18372
- this.__update(evaluationRuleId, request, requestOptions)
18373
- );
18374
- }
18375
- async __update(evaluationRuleId, request, requestOptions) {
18376
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18377
- let _headers = mergeHeaders(
18378
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18379
- mergeOnlyDefinedHeaders({
18380
- Authorization: await this._getAuthorizationHeader(),
18381
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18382
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18383
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18384
- }),
18385
- requestOptions == null ? void 0 : requestOptions.headers
18386
- );
18387
- const _response = await fetcher({
18388
- url: url_exports.join(
18389
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18390
- `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
18391
- ),
18392
- method: "PATCH",
18393
- headers: _headers,
18394
- contentType: "application/json",
18395
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
18396
- requestType: "json",
18397
- body: request,
18398
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18399
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18400
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18401
- });
18402
- if (_response.ok) {
18403
- return {
18404
- data: _response.body,
18405
- rawResponse: _response.rawResponse
18406
- };
18407
- }
18408
- if (_response.error.reason === "status-code") {
18409
- switch (_response.error.statusCode) {
18410
- case 400:
18411
- throw new unstable_exports.BadRequestError(
18412
- _response.error.body,
18413
- _response.rawResponse
18414
- );
18415
- case 401:
18416
- throw new unstable_exports.UnauthorizedError(
18417
- _response.error.body,
18418
- _response.rawResponse
18419
- );
18420
- case 403:
18421
- throw new unstable_exports.AccessDeniedError(
18422
- _response.error.body,
18423
- _response.rawResponse
18424
- );
18425
- case 404:
18426
- throw new unstable_exports.NotFoundError(
18427
- _response.error.body,
18428
- _response.rawResponse
18429
- );
18430
- case 405:
18431
- throw new unstable_exports.MethodNotAllowedError(
18432
- _response.error.body,
18433
- _response.rawResponse
18434
- );
18435
- case 422:
18436
- throw new unstable_exports.UnprocessableContentError(
18437
- _response.error.body,
18438
- _response.rawResponse
18439
- );
18440
- case 429:
18441
- throw new unstable_exports.TooManyRequestsError(
18442
- _response.error.body,
18443
- _response.rawResponse
18444
- );
18445
- case 500:
18446
- throw new unstable_exports.InternalServerError(
18447
- _response.error.body,
18448
- _response.rawResponse
18449
- );
18450
- case 400:
18451
- throw new Error2(
18452
- _response.error.body,
18453
- _response.rawResponse
18454
- );
18455
- case 401:
18456
- throw new UnauthorizedError(
18457
- _response.error.body,
18458
- _response.rawResponse
18459
- );
18460
- case 403:
18461
- throw new AccessDeniedError(
18462
- _response.error.body,
18463
- _response.rawResponse
18464
- );
18465
- case 405:
18466
- throw new MethodNotAllowedError(
18467
- _response.error.body,
18468
- _response.rawResponse
18469
- );
18470
- case 404:
18471
- throw new NotFoundError(
18472
- _response.error.body,
18473
- _response.rawResponse
18474
- );
18475
- default:
18476
- throw new LangfuseAPIError({
18477
- statusCode: _response.error.statusCode,
18478
- body: _response.error.body,
18479
- rawResponse: _response.rawResponse
18480
- });
18481
- }
18482
- }
18483
- switch (_response.error.reason) {
18484
- case "non-json":
18485
- throw new LangfuseAPIError({
18486
- statusCode: _response.error.statusCode,
18487
- body: _response.error.rawBody,
18488
- rawResponse: _response.rawResponse
18489
- });
18490
- case "timeout":
18491
- throw new LangfuseAPITimeoutError(
18492
- "Timeout exceeded when calling PATCH /api/public/unstable/evaluation-rules/{evaluationRuleId}."
18493
- );
18494
- case "unknown":
18495
- throw new LangfuseAPIError({
18496
- message: _response.error.errorMessage,
18497
- rawResponse: _response.rawResponse
18498
- });
18499
- }
18500
- }
18501
- /**
18502
- * Delete an evaluation rule.
18503
- *
18504
- * This removes the live-ingestion rule only. It does not delete the referenced evaluator.
18505
- *
18506
- * @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.
18507
- *
18508
- * @param {string} evaluationRuleId - Evaluation rule identifier.
18509
- * @param {EvaluationRules.RequestOptions} requestOptions - Request-specific configuration.
18510
- *
18511
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18512
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18513
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18514
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
18515
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18516
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18517
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18518
- * @throws {@link LangfuseAPI.Error}
18519
- * @throws {@link LangfuseAPI.UnauthorizedError}
18520
- * @throws {@link LangfuseAPI.AccessDeniedError}
18521
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18522
- * @throws {@link LangfuseAPI.NotFoundError}
18523
- *
18524
- * @example
18525
- * await client.unstable.evaluationRules.delete("evaluationRuleId")
18526
- */
18527
- delete(evaluationRuleId, requestOptions) {
18528
- return HttpResponsePromise.fromPromise(
18529
- this.__delete(evaluationRuleId, requestOptions)
18530
- );
18531
- }
18532
- async __delete(evaluationRuleId, requestOptions) {
18533
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18534
- let _headers = mergeHeaders(
18535
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18536
- mergeOnlyDefinedHeaders({
18537
- Authorization: await this._getAuthorizationHeader(),
18538
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18539
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18540
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18541
- }),
18542
- requestOptions == null ? void 0 : requestOptions.headers
18543
- );
18544
- const _response = await fetcher({
18545
- url: url_exports.join(
18546
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18547
- `/api/public/unstable/evaluation-rules/${encodeURIComponent(evaluationRuleId)}`
18548
- ),
18549
- method: "DELETE",
18550
- headers: _headers,
18551
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
18552
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18553
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18554
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18555
- });
18556
- if (_response.ok) {
18557
- return {
18558
- data: _response.body,
18559
- rawResponse: _response.rawResponse
18560
- };
18561
- }
18562
- if (_response.error.reason === "status-code") {
18563
- switch (_response.error.statusCode) {
18564
- case 400:
18565
- throw new unstable_exports.BadRequestError(
18566
- _response.error.body,
18567
- _response.rawResponse
18568
- );
18569
- case 401:
18570
- throw new unstable_exports.UnauthorizedError(
18571
- _response.error.body,
18572
- _response.rawResponse
18573
- );
18574
- case 403:
18575
- throw new unstable_exports.AccessDeniedError(
18576
- _response.error.body,
18577
- _response.rawResponse
18578
- );
18579
- case 404:
18580
- throw new unstable_exports.NotFoundError(
18581
- _response.error.body,
18582
- _response.rawResponse
18583
- );
18584
- case 405:
18585
- throw new unstable_exports.MethodNotAllowedError(
18586
- _response.error.body,
18587
- _response.rawResponse
18588
- );
18589
- case 429:
18590
- throw new unstable_exports.TooManyRequestsError(
18591
- _response.error.body,
18592
- _response.rawResponse
18593
- );
18594
- case 500:
18595
- throw new unstable_exports.InternalServerError(
18596
- _response.error.body,
18597
- _response.rawResponse
18598
- );
18599
- case 400:
18600
- throw new Error2(
18601
- _response.error.body,
18602
- _response.rawResponse
18603
- );
18604
- case 401:
18605
- throw new UnauthorizedError(
18606
- _response.error.body,
18607
- _response.rawResponse
18608
- );
18609
- case 403:
18610
- throw new AccessDeniedError(
18611
- _response.error.body,
18612
- _response.rawResponse
18613
- );
18614
- case 405:
18615
- throw new MethodNotAllowedError(
18616
- _response.error.body,
18617
- _response.rawResponse
18618
- );
18619
- case 404:
18620
- throw new NotFoundError(
18621
- _response.error.body,
18622
- _response.rawResponse
18623
- );
18624
- default:
18625
- throw new LangfuseAPIError({
18626
- statusCode: _response.error.statusCode,
18627
- body: _response.error.body,
18628
- rawResponse: _response.rawResponse
18629
- });
18630
- }
18631
- }
18632
- switch (_response.error.reason) {
18633
- case "non-json":
18634
- throw new LangfuseAPIError({
18635
- statusCode: _response.error.statusCode,
18636
- body: _response.error.rawBody,
18637
- rawResponse: _response.rawResponse
18638
- });
18639
- case "timeout":
18640
- throw new LangfuseAPITimeoutError(
18641
- "Timeout exceeded when calling DELETE /api/public/unstable/evaluation-rules/{evaluationRuleId}."
18642
- );
18643
- case "unknown":
18644
- throw new LangfuseAPIError({
18645
- message: _response.error.errorMessage,
18646
- rawResponse: _response.rawResponse
18647
- });
18648
- }
18649
- }
18650
- async _getAuthorizationHeader() {
18651
- const username = await Supplier.get(this._options.username);
18652
- const password = await Supplier.get(this._options.password);
18653
- if (username != null && password != null) {
18654
- return BasicAuth.toAuthorizationHeader({
18655
- username,
18656
- password
18657
- });
18658
- }
18659
- return void 0;
18660
- }
18661
- };
18662
-
18663
- // src/api/api/resources/unstable/resources/evaluators/client/Client.ts
18664
- var Evaluators2 = class {
18665
- constructor(_options) {
18666
- this._options = _options;
18667
- }
18668
- /**
18669
- * Create an evaluator in the authenticated project.
18670
- *
18671
- * Use evaluators to define **how** Langfuse should score data.
18672
- * LLM-as-a-judge evaluators define a prompt, expected structured output, and optional model configuration.
18673
- * Code evaluators define source code and a runtime language.
18674
- *
18675
- * Naming behavior:
18676
- * - If this is a new evaluator name in your project, Langfuse creates version `1`.
18677
- * - If the name already exists in your project, Langfuse creates the next version and returns it.
18678
- * - The evaluator `id` remains stable across versions.
18679
- * - Existing evaluation rules automatically use the latest evaluator version; no rule update is required.
18680
- *
18681
- * Recommended workflow:
18682
- * 1. Create the evaluator.
18683
- * 2. Read the returned `variables` array.
18684
- * 3. Read the returned `outputDefinition.dataType` so the client knows whether future scores will be numeric, boolean, or categorical.
18685
- * 4. Create one or more evaluation rules that reference the returned evaluator family using `name` and `type`.
18686
- *
18687
- * Code evaluator validation:
18688
- * - At creation, Langfuse only validates the request shape
18689
- * - 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.
18690
- *
18691
- * Recovery guidance:
18692
- * - `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.
18693
- * - `400` with `code=invalid_body`: the request shape is malformed. Use the structured `details.issues` array to fix the specific fields and retry.
18694
- * - `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.
18695
- * - If `type` is omitted, Langfuse treats the request as `type=llm_as_judge` for backwards compatibility. New clients should send `type` explicitly.
18696
- *
18697
- * Unstable API note:
18698
- * - This surface may evolve while the underlying evaluation data model is being redesigned.
18699
- *
18700
- * @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.
18701
- *
18702
- * @param {LangfuseAPI.unstable.CreateEvaluatorRequest} request
18703
- * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
18704
- *
18705
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18706
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18707
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18708
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18709
- * @throws {@link LangfuseAPI.unstable.ConflictError}
18710
- * @throws {@link LangfuseAPI.unstable.UnprocessableContentError}
18711
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18712
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18713
- * @throws {@link LangfuseAPI.Error}
18714
- * @throws {@link LangfuseAPI.UnauthorizedError}
18715
- * @throws {@link LangfuseAPI.AccessDeniedError}
18716
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18717
- * @throws {@link LangfuseAPI.NotFoundError}
18718
- *
18719
- * @example
18720
- * await client.unstable.evaluators.create({
18721
- * type: "llm_as_judge",
18722
- * name: "answer-correctness",
18723
- * prompt: "You are grading an answer.\n\nInput:\n{{input}}\n\nOutput:\n{{output}}\n\nReturn a score between 0 and 1.\n",
18724
- * outputDefinition: {
18725
- * dataType: "NUMERIC",
18726
- * dataType: "NUMERIC",
18727
- * reasoning: {
18728
- * description: "Explain why the score was assigned."
18729
- * },
18730
- * score: {
18731
- * description: "Correctness score between 0 and 1."
18732
- * }
18733
- * },
18734
- * modelConfig: {
18735
- * provider: "openai",
18736
- * model: "gpt-4.1-mini"
18737
- * },
18738
- * mapping: [{
18739
- * variable: "input",
18740
- * source: "input"
18741
- * }, {
18742
- * variable: "output",
18743
- * source: "output"
18744
- * }]
18745
- * })
18746
- *
18747
- * @example
18748
- * await client.unstable.evaluators.create({
18749
- * type: "code",
18750
- * name: "exact-match",
18751
- * 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",
18752
- * sourceCodeLanguage: "TYPESCRIPT"
18753
- * })
18754
- *
18755
- * @example
18756
- * await client.unstable.evaluators.create({
18757
- * type: "code",
18758
- * name: "exact-match",
18759
- * 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",
18760
- * sourceCodeLanguage: "PYTHON"
18761
- * })
18762
- */
18763
- create(request, requestOptions) {
18764
- return HttpResponsePromise.fromPromise(
18765
- this.__create(request, requestOptions)
18766
- );
18767
- }
18768
- async __create(request, requestOptions) {
18769
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18770
- let _headers = mergeHeaders(
18771
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18772
- mergeOnlyDefinedHeaders({
18773
- Authorization: await this._getAuthorizationHeader(),
18774
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18775
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18776
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18777
- }),
18778
- requestOptions == null ? void 0 : requestOptions.headers
18779
- );
18780
- const _response = await fetcher({
18781
- url: url_exports.join(
18782
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18783
- "/api/public/unstable/evaluators"
18784
- ),
18785
- method: "POST",
18786
- headers: _headers,
18787
- contentType: "application/json",
18788
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
18789
- requestType: "json",
18790
- body: request,
18791
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18792
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18793
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18794
- });
18795
- if (_response.ok) {
18796
- return {
18797
- data: _response.body,
18798
- rawResponse: _response.rawResponse
18799
- };
18800
- }
18801
- if (_response.error.reason === "status-code") {
18802
- switch (_response.error.statusCode) {
18803
- case 400:
18804
- throw new unstable_exports.BadRequestError(
18805
- _response.error.body,
18806
- _response.rawResponse
18807
- );
18808
- case 401:
18809
- throw new unstable_exports.UnauthorizedError(
18810
- _response.error.body,
18811
- _response.rawResponse
18812
- );
18813
- case 403:
18814
- throw new unstable_exports.AccessDeniedError(
18815
- _response.error.body,
18816
- _response.rawResponse
18817
- );
18818
- case 405:
18819
- throw new unstable_exports.MethodNotAllowedError(
18820
- _response.error.body,
18821
- _response.rawResponse
18822
- );
18823
- case 409:
18824
- throw new unstable_exports.ConflictError(
18825
- _response.error.body,
18826
- _response.rawResponse
18827
- );
18828
- case 422:
18829
- throw new unstable_exports.UnprocessableContentError(
18830
- _response.error.body,
18831
- _response.rawResponse
18832
- );
18833
- case 429:
18834
- throw new unstable_exports.TooManyRequestsError(
18835
- _response.error.body,
18836
- _response.rawResponse
18837
- );
18838
- case 500:
18839
- throw new unstable_exports.InternalServerError(
18840
- _response.error.body,
18841
- _response.rawResponse
18842
- );
18843
- case 400:
18844
- throw new Error2(
18845
- _response.error.body,
18846
- _response.rawResponse
18847
- );
18848
- case 401:
18849
- throw new UnauthorizedError(
18850
- _response.error.body,
18851
- _response.rawResponse
18852
- );
18853
- case 403:
18854
- throw new AccessDeniedError(
18855
- _response.error.body,
18856
- _response.rawResponse
18857
- );
18858
- case 405:
18859
- throw new MethodNotAllowedError(
18860
- _response.error.body,
18861
- _response.rawResponse
18862
- );
18863
- case 404:
18864
- throw new NotFoundError(
18865
- _response.error.body,
18866
- _response.rawResponse
18867
- );
18868
- default:
18869
- throw new LangfuseAPIError({
18870
- statusCode: _response.error.statusCode,
18871
- body: _response.error.body,
18872
- rawResponse: _response.rawResponse
18873
- });
18874
- }
18875
- }
18876
- switch (_response.error.reason) {
18877
- case "non-json":
18878
- throw new LangfuseAPIError({
18879
- statusCode: _response.error.statusCode,
18880
- body: _response.error.rawBody,
18881
- rawResponse: _response.rawResponse
18882
- });
18883
- case "timeout":
18884
- throw new LangfuseAPITimeoutError(
18885
- "Timeout exceeded when calling POST /api/public/unstable/evaluators."
18886
- );
18887
- case "unknown":
18888
- throw new LangfuseAPIError({
18889
- message: _response.error.errorMessage,
18890
- rawResponse: _response.rawResponse
18891
- });
18892
- }
18893
- }
18894
- /**
18895
- * List the evaluators available to the authenticated project.
18896
- *
18897
- * Important behavior:
18898
- * - This endpoint returns the latest version of each available evaluator.
18899
- * - Every evaluator is owned by the authenticated project.
18900
- *
18901
- * @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.
18902
- *
18903
- * @param {LangfuseAPI.unstable.ListEvaluatorsRequest} request
18904
- * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
18905
- *
18906
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
18907
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
18908
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
18909
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
18910
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
18911
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
18912
- * @throws {@link LangfuseAPI.Error}
18913
- * @throws {@link LangfuseAPI.UnauthorizedError}
18914
- * @throws {@link LangfuseAPI.AccessDeniedError}
18915
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
18916
- * @throws {@link LangfuseAPI.NotFoundError}
18917
- *
18918
- * @example
18919
- * await client.unstable.evaluators.list()
18920
- */
18921
- list(request = {}, requestOptions) {
18922
- return HttpResponsePromise.fromPromise(
18923
- this.__list(request, requestOptions)
18924
- );
18925
- }
18926
- async __list(request = {}, requestOptions) {
18927
- var _a2, _b, _c, _d, _e, _f, _g, _h;
18928
- const { page, limit } = request;
18929
- const _queryParams = {};
18930
- if (page != null) {
18931
- _queryParams["page"] = page.toString();
18932
- }
18933
- if (limit != null) {
18934
- _queryParams["limit"] = limit.toString();
18935
- }
18936
- let _headers = mergeHeaders(
18937
- (_a2 = this._options) == null ? void 0 : _a2.headers,
18938
- mergeOnlyDefinedHeaders({
18939
- Authorization: await this._getAuthorizationHeader(),
18940
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
18941
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
18942
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
18943
- }),
18944
- requestOptions == null ? void 0 : requestOptions.headers
18945
- );
18946
- const _response = await fetcher({
18947
- url: url_exports.join(
18948
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
18949
- "/api/public/unstable/evaluators"
18950
- ),
18951
- method: "GET",
18952
- headers: _headers,
18953
- queryParameters: { ..._queryParams, ...requestOptions == null ? void 0 : requestOptions.queryParams },
18954
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
18955
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
18956
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
18957
- });
18958
- if (_response.ok) {
18959
- return {
18960
- data: _response.body,
18961
- rawResponse: _response.rawResponse
18962
- };
18963
- }
18964
- if (_response.error.reason === "status-code") {
18965
- switch (_response.error.statusCode) {
18966
- case 400:
18967
- throw new unstable_exports.BadRequestError(
18968
- _response.error.body,
18969
- _response.rawResponse
18970
- );
18971
- case 401:
18972
- throw new unstable_exports.UnauthorizedError(
18973
- _response.error.body,
18974
- _response.rawResponse
18975
- );
18976
- case 403:
18977
- throw new unstable_exports.AccessDeniedError(
18978
- _response.error.body,
18979
- _response.rawResponse
18980
- );
18981
- case 405:
18982
- throw new unstable_exports.MethodNotAllowedError(
18983
- _response.error.body,
18984
- _response.rawResponse
18985
- );
18986
- case 429:
18987
- throw new unstable_exports.TooManyRequestsError(
18988
- _response.error.body,
18989
- _response.rawResponse
18990
- );
18991
- case 500:
18992
- throw new unstable_exports.InternalServerError(
18993
- _response.error.body,
18994
- _response.rawResponse
18995
- );
18996
- case 400:
18997
- throw new Error2(
18998
- _response.error.body,
18999
- _response.rawResponse
19000
- );
19001
- case 401:
19002
- throw new UnauthorizedError(
19003
- _response.error.body,
19004
- _response.rawResponse
19005
- );
19006
- case 403:
19007
- throw new AccessDeniedError(
19008
- _response.error.body,
19009
- _response.rawResponse
19010
- );
19011
- case 405:
19012
- throw new MethodNotAllowedError(
19013
- _response.error.body,
19014
- _response.rawResponse
19015
- );
19016
- case 404:
19017
- throw new NotFoundError(
19018
- _response.error.body,
19019
- _response.rawResponse
19020
- );
19021
- default:
19022
- throw new LangfuseAPIError({
19023
- statusCode: _response.error.statusCode,
19024
- body: _response.error.body,
19025
- rawResponse: _response.rawResponse
19026
- });
19027
- }
19028
- }
19029
- switch (_response.error.reason) {
19030
- case "non-json":
19031
- throw new LangfuseAPIError({
19032
- statusCode: _response.error.statusCode,
19033
- body: _response.error.rawBody,
19034
- rawResponse: _response.rawResponse
19035
- });
19036
- case "timeout":
19037
- throw new LangfuseAPITimeoutError(
19038
- "Timeout exceeded when calling GET /api/public/unstable/evaluators."
19039
- );
19040
- case "unknown":
19041
- throw new LangfuseAPIError({
19042
- message: _response.error.errorMessage,
19043
- rawResponse: _response.rawResponse
19044
- });
19045
- }
19046
- }
19047
- /**
19048
- * Get one evaluator by `id`.
19049
- *
19050
- * 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.
19051
- *
19052
- * @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.
19053
- *
19054
- * @param {string} evaluatorId - Evaluator identifier returned by the evaluator endpoints.
19055
- * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
19056
- *
19057
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
19058
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
19059
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
19060
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
19061
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
19062
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
19063
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
19064
- * @throws {@link LangfuseAPI.Error}
19065
- * @throws {@link LangfuseAPI.UnauthorizedError}
19066
- * @throws {@link LangfuseAPI.AccessDeniedError}
19067
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
19068
- * @throws {@link LangfuseAPI.NotFoundError}
19069
- *
19070
- * @example
19071
- * await client.unstable.evaluators.get("evaluatorId")
19072
- */
19073
- get(evaluatorId, requestOptions) {
19074
- return HttpResponsePromise.fromPromise(
19075
- this.__get(evaluatorId, requestOptions)
19076
- );
19077
- }
19078
- async __get(evaluatorId, requestOptions) {
19079
- var _a2, _b, _c, _d, _e, _f, _g, _h;
19080
- let _headers = mergeHeaders(
19081
- (_a2 = this._options) == null ? void 0 : _a2.headers,
19082
- mergeOnlyDefinedHeaders({
19083
- Authorization: await this._getAuthorizationHeader(),
19084
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
19085
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
19086
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
19087
- }),
19088
- requestOptions == null ? void 0 : requestOptions.headers
19089
- );
19090
- const _response = await fetcher({
19091
- url: url_exports.join(
19092
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
19093
- `/api/public/unstable/evaluators/${encodeURIComponent(evaluatorId)}`
19094
- ),
19095
- method: "GET",
19096
- headers: _headers,
19097
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
19098
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
19099
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
19100
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
19101
- });
19102
- if (_response.ok) {
19103
- return {
19104
- data: _response.body,
19105
- rawResponse: _response.rawResponse
19106
- };
19107
- }
19108
- if (_response.error.reason === "status-code") {
19109
- switch (_response.error.statusCode) {
19110
- case 400:
19111
- throw new unstable_exports.BadRequestError(
19112
- _response.error.body,
19113
- _response.rawResponse
19114
- );
19115
- case 401:
19116
- throw new unstable_exports.UnauthorizedError(
19117
- _response.error.body,
19118
- _response.rawResponse
19119
- );
19120
- case 403:
19121
- throw new unstable_exports.AccessDeniedError(
19122
- _response.error.body,
19123
- _response.rawResponse
19124
- );
19125
- case 404:
19126
- throw new unstable_exports.NotFoundError(
19127
- _response.error.body,
19128
- _response.rawResponse
19129
- );
19130
- case 405:
19131
- throw new unstable_exports.MethodNotAllowedError(
19132
- _response.error.body,
19133
- _response.rawResponse
19134
- );
19135
- case 429:
19136
- throw new unstable_exports.TooManyRequestsError(
19137
- _response.error.body,
19138
- _response.rawResponse
19139
- );
19140
- case 500:
19141
- throw new unstable_exports.InternalServerError(
19142
- _response.error.body,
19143
- _response.rawResponse
19144
- );
19145
- case 400:
19146
- throw new Error2(
19147
- _response.error.body,
19148
- _response.rawResponse
19149
- );
19150
- case 401:
19151
- throw new UnauthorizedError(
19152
- _response.error.body,
19153
- _response.rawResponse
19154
- );
19155
- case 403:
19156
- throw new AccessDeniedError(
19157
- _response.error.body,
19158
- _response.rawResponse
19159
- );
19160
- case 405:
19161
- throw new MethodNotAllowedError(
19162
- _response.error.body,
19163
- _response.rawResponse
19164
- );
19165
- case 404:
19166
- throw new NotFoundError(
19167
- _response.error.body,
19168
- _response.rawResponse
19169
- );
19170
- default:
19171
- throw new LangfuseAPIError({
19172
- statusCode: _response.error.statusCode,
19173
- body: _response.error.body,
19174
- rawResponse: _response.rawResponse
19175
- });
19176
- }
19177
- }
19178
- switch (_response.error.reason) {
19179
- case "non-json":
19180
- throw new LangfuseAPIError({
19181
- statusCode: _response.error.statusCode,
19182
- body: _response.error.rawBody,
19183
- rawResponse: _response.rawResponse
19184
- });
19185
- case "timeout":
19186
- throw new LangfuseAPITimeoutError(
19187
- "Timeout exceeded when calling GET /api/public/unstable/evaluators/{evaluatorId}."
19188
- );
19189
- case "unknown":
19190
- throw new LangfuseAPIError({
19191
- message: _response.error.errorMessage,
19192
- rawResponse: _response.rawResponse
19193
- });
19194
- }
19195
- }
19196
- /**
19197
- * Delete an evaluator.
19198
- *
19199
- * Important behavior:
19200
- * - This deletes the evaluator including all of its stored versions.
19201
- * - Evaluation rule assignments referencing the evaluator are also deleted.
19202
- * - Scores already produced by the evaluator are not deleted.
19203
- *
19204
- * @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.
19205
- *
19206
- * @param {string} evaluatorId - Evaluator identifier returned by the evaluator endpoints.
19207
- * @param {Evaluators.RequestOptions} requestOptions - Request-specific configuration.
19208
- *
19209
- * @throws {@link LangfuseAPI.unstable.BadRequestError}
19210
- * @throws {@link LangfuseAPI.unstable.UnauthorizedError}
19211
- * @throws {@link LangfuseAPI.unstable.AccessDeniedError}
19212
- * @throws {@link LangfuseAPI.unstable.NotFoundError}
19213
- * @throws {@link LangfuseAPI.unstable.MethodNotAllowedError}
19214
- * @throws {@link LangfuseAPI.unstable.TooManyRequestsError}
19215
- * @throws {@link LangfuseAPI.unstable.InternalServerError}
19216
- * @throws {@link LangfuseAPI.Error}
19217
- * @throws {@link LangfuseAPI.UnauthorizedError}
19218
- * @throws {@link LangfuseAPI.AccessDeniedError}
19219
- * @throws {@link LangfuseAPI.MethodNotAllowedError}
19220
- * @throws {@link LangfuseAPI.NotFoundError}
19221
- *
19222
- * @example
19223
- * await client.unstable.evaluators.delete("evaluatorId")
19224
- */
19225
- delete(evaluatorId, requestOptions) {
19226
- return HttpResponsePromise.fromPromise(
19227
- this.__delete(evaluatorId, requestOptions)
19228
- );
19229
- }
19230
- async __delete(evaluatorId, requestOptions) {
19231
- var _a2, _b, _c, _d, _e, _f, _g, _h;
19232
- let _headers = mergeHeaders(
19233
- (_a2 = this._options) == null ? void 0 : _a2.headers,
19234
- mergeOnlyDefinedHeaders({
19235
- Authorization: await this._getAuthorizationHeader(),
19236
- "X-Langfuse-Sdk-Name": (_c = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkName) != null ? _c : (_b = this._options) == null ? void 0 : _b.xLangfuseSdkName,
19237
- "X-Langfuse-Sdk-Version": (_e = requestOptions == null ? void 0 : requestOptions.xLangfuseSdkVersion) != null ? _e : (_d = this._options) == null ? void 0 : _d.xLangfuseSdkVersion,
19238
- "X-Langfuse-Public-Key": (_g = requestOptions == null ? void 0 : requestOptions.xLangfusePublicKey) != null ? _g : (_f = this._options) == null ? void 0 : _f.xLangfusePublicKey
19239
- }),
19240
- requestOptions == null ? void 0 : requestOptions.headers
19241
- );
19242
- const _response = await fetcher({
19243
- url: url_exports.join(
19244
- (_h = await Supplier.get(this._options.baseUrl)) != null ? _h : await Supplier.get(this._options.environment),
19245
- `/api/public/unstable/evaluators/${encodeURIComponent(evaluatorId)}`
19246
- ),
19247
- method: "DELETE",
19248
- headers: _headers,
19249
- queryParameters: requestOptions == null ? void 0 : requestOptions.queryParams,
19250
- timeoutMs: (requestOptions == null ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
19251
- maxRetries: requestOptions == null ? void 0 : requestOptions.maxRetries,
19252
- abortSignal: requestOptions == null ? void 0 : requestOptions.abortSignal
19253
- });
19254
- if (_response.ok) {
19255
- return {
19256
- data: _response.body,
19257
- rawResponse: _response.rawResponse
19258
- };
19259
- }
19260
- if (_response.error.reason === "status-code") {
19261
- switch (_response.error.statusCode) {
19262
- case 400:
19263
- throw new unstable_exports.BadRequestError(
19264
- _response.error.body,
19265
- _response.rawResponse
19266
- );
19267
- case 401:
19268
- throw new unstable_exports.UnauthorizedError(
19269
- _response.error.body,
19270
- _response.rawResponse
19271
- );
19272
- case 403:
19273
- throw new unstable_exports.AccessDeniedError(
19274
- _response.error.body,
19275
- _response.rawResponse
19276
- );
19277
- case 404:
19278
- throw new unstable_exports.NotFoundError(
19279
- _response.error.body,
19280
- _response.rawResponse
19281
- );
19282
- case 405:
19283
- throw new unstable_exports.MethodNotAllowedError(
19284
- _response.error.body,
19285
- _response.rawResponse
19286
- );
19287
- case 429:
19288
- throw new unstable_exports.TooManyRequestsError(
19289
- _response.error.body,
19290
- _response.rawResponse
19291
- );
19292
- case 500:
19293
- throw new unstable_exports.InternalServerError(
19294
- _response.error.body,
19295
- _response.rawResponse
19296
- );
19297
- case 400:
19298
- throw new Error2(
19299
- _response.error.body,
19300
- _response.rawResponse
19301
- );
19302
- case 401:
19303
- throw new UnauthorizedError(
19304
- _response.error.body,
19305
- _response.rawResponse
19306
- );
19307
- case 403:
19308
- throw new AccessDeniedError(
19309
- _response.error.body,
19310
- _response.rawResponse
19311
- );
19312
- case 405:
19313
- throw new MethodNotAllowedError(
19314
- _response.error.body,
19315
- _response.rawResponse
19316
- );
19317
- case 404:
19318
- throw new NotFoundError(
19319
- _response.error.body,
19320
- _response.rawResponse
19321
- );
19322
- default:
19323
- throw new LangfuseAPIError({
19324
- statusCode: _response.error.statusCode,
19325
- body: _response.error.body,
19326
- rawResponse: _response.rawResponse
19327
- });
19328
- }
19329
- }
19330
- switch (_response.error.reason) {
19331
- case "non-json":
19332
- throw new LangfuseAPIError({
19333
- statusCode: _response.error.statusCode,
19334
- body: _response.error.rawBody,
19335
- rawResponse: _response.rawResponse
19336
- });
19337
- case "timeout":
19338
- throw new LangfuseAPITimeoutError(
19339
- "Timeout exceeded when calling DELETE /api/public/unstable/evaluators/{evaluatorId}."
19340
- );
19341
- case "unknown":
19342
- throw new LangfuseAPIError({
19343
- message: _response.error.errorMessage,
19344
- rawResponse: _response.rawResponse
19345
- });
19346
- }
19347
- }
19348
- async _getAuthorizationHeader() {
19349
- const username = await Supplier.get(this._options.username);
19350
- const password = await Supplier.get(this._options.password);
19351
- if (username != null && password != null) {
19352
- return BasicAuth.toAuthorizationHeader({
19353
- username,
19354
- password
19355
- });
19356
- }
19357
- return void 0;
19358
- }
19359
- };
19360
-
19361
- // src/api/api/resources/unstable/client/Client.ts
19362
- var Unstable = class {
19363
- constructor(_options) {
19364
- this._options = _options;
19365
- }
19366
- get dashboardWidgets() {
19367
- var _a2;
19368
- return (_a2 = this._dashboardWidgets) != null ? _a2 : this._dashboardWidgets = new DashboardWidgets(this._options);
17571
+ get dashboardWidgets() {
17572
+ var _a2;
17573
+ return (_a2 = this._dashboardWidgets) != null ? _a2 : this._dashboardWidgets = new DashboardWidgets(this._options);
19369
17574
  }
19370
17575
  get dashboards() {
19371
17576
  var _a2;
19372
17577
  return (_a2 = this._dashboards) != null ? _a2 : this._dashboards = new Dashboards(this._options);
19373
17578
  }
19374
- get evaluationRules() {
19375
- var _a2;
19376
- return (_a2 = this._evaluationRules) != null ? _a2 : this._evaluationRules = new EvaluationRules2(this._options);
19377
- }
19378
- get evaluators() {
19379
- var _a2;
19380
- return (_a2 = this._evaluators) != null ? _a2 : this._evaluators = new Evaluators2(this._options);
19381
- }
19382
17579
  };
19383
17580
 
19384
17581
  // src/api/Client.ts
@@ -20446,6 +18643,7 @@ function getSpanKeyFromBaggageKey(baggageKey) {
20446
18643
  EvaluationRuleOptionsFilterOperator,
20447
18644
  EvaluationRuleStringFilterOperator,
20448
18645
  EvaluationUnauthorizedError,
18646
+ EvaluatorChatMessageRole,
20449
18647
  EvaluatorOutputScoreType,
20450
18648
  EvaluatorStatus,
20451
18649
  EvaluatorType,