From a48d028134aa52be83b600d6fa5ffb61a805c0cd Mon Sep 17 00:00:00 2001 From: langfuse-bot Date: Mon, 31 Aug 2026 06:55:33 +0000 Subject: [PATCH] feat(api): update API spec from langfuse/langfuse 4e0ce09 --- langfuse/api/unstable/__init__.py | 3 + .../api/unstable/evaluation_rules/__init__.py | 3 + .../api/unstable/evaluation_rules/client.py | 9 +- .../unstable/evaluation_rules/raw_client.py | 17 +-- .../evaluation_rules/types/__init__.py | 3 + .../evaluation_rules/types/evaluation_rule.py | 77 ------------ .../types/readable_evaluation_rule.py | 4 +- .../types/readable_v2evaluation_rule.py | 115 ++++++++++++++++++ 8 files changed, 140 insertions(+), 91 deletions(-) create mode 100644 langfuse/api/unstable/evaluation_rules/types/readable_v2evaluation_rule.py diff --git a/langfuse/api/unstable/__init__.py b/langfuse/api/unstable/__init__.py index 84a0cbfa7..1b6c232dd 100644 --- a/langfuse/api/unstable/__init__.py +++ b/langfuse/api/unstable/__init__.py @@ -143,6 +143,7 @@ LlmAsJudgeEvaluationRuleEvaluatorReference, LlmAsJudgeEvaluatorType, ReadableEvaluationRule, + ReadableV2EvaluationRule, UpdateEvaluationRuleRequest, ) from .evaluators import ( @@ -284,6 +285,7 @@ "PublicNumericEvaluatorOutputDefinition": ".commons", "PublicNumericEvaluatorOutputScoreDefinition": ".commons", "ReadableEvaluationRule": ".evaluation_rules", + "ReadableV2EvaluationRule": ".evaluation_rules", "StringEvaluationRuleFilter": ".commons", "StringObjectEvaluationRuleFilter": ".commons", "StringOptionsEvaluationRuleFilter": ".commons", @@ -455,6 +457,7 @@ def __dir__(): "PublicNumericEvaluatorOutputDefinition", "PublicNumericEvaluatorOutputScoreDefinition", "ReadableEvaluationRule", + "ReadableV2EvaluationRule", "StringEvaluationRuleFilter", "StringObjectEvaluationRuleFilter", "StringOptionsEvaluationRuleFilter", diff --git a/langfuse/api/unstable/evaluation_rules/__init__.py b/langfuse/api/unstable/evaluation_rules/__init__.py index 478b15189..34995580f 100644 --- a/langfuse/api/unstable/evaluation_rules/__init__.py +++ b/langfuse/api/unstable/evaluation_rules/__init__.py @@ -30,6 +30,7 @@ LlmAsJudgeEvaluationRuleEvaluatorReference, LlmAsJudgeEvaluatorType, ReadableEvaluationRule, + ReadableV2EvaluationRule, UpdateEvaluationRuleRequest, ) _dynamic_imports: typing.Dict[str, str] = { @@ -56,6 +57,7 @@ "LlmAsJudgeEvaluationRuleEvaluatorReference": ".types", "LlmAsJudgeEvaluatorType": ".types", "ReadableEvaluationRule": ".types", + "ReadableV2EvaluationRule": ".types", "UpdateEvaluationRuleRequest": ".types", } @@ -111,5 +113,6 @@ def __dir__(): "LlmAsJudgeEvaluationRuleEvaluatorReference", "LlmAsJudgeEvaluatorType", "ReadableEvaluationRule", + "ReadableV2EvaluationRule", "UpdateEvaluationRuleRequest", ] diff --git a/langfuse/api/unstable/evaluation_rules/client.py b/langfuse/api/unstable/evaluation_rules/client.py index 8f2bbab35..7fe839ffe 100644 --- a/langfuse/api/unstable/evaluation_rules/client.py +++ b/langfuse/api/unstable/evaluation_rules/client.py @@ -18,6 +18,7 @@ from .types.evaluation_rule_evaluator_reference import EvaluationRuleEvaluatorReference from .types.evaluation_rules import EvaluationRules from .types.readable_evaluation_rule import ReadableEvaluationRule +from .types.readable_v2evaluation_rule import ReadableV2EvaluationRule # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -275,7 +276,7 @@ def update( filter: typing.Optional[typing.Sequence[EvaluationRuleFilter]] = OMIT, mapping: typing.Optional[typing.Sequence[PromptVariableMappingInput]] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> EvaluationRule: + ) -> ReadableV2EvaluationRule: """ Update an evaluation rule. @@ -343,7 +344,7 @@ def update( Returns ------- - EvaluationRule + ReadableV2EvaluationRule Examples -------- @@ -700,7 +701,7 @@ async def update( filter: typing.Optional[typing.Sequence[EvaluationRuleFilter]] = OMIT, mapping: typing.Optional[typing.Sequence[PromptVariableMappingInput]] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> EvaluationRule: + ) -> ReadableV2EvaluationRule: """ Update an evaluation rule. @@ -768,7 +769,7 @@ async def update( Returns ------- - EvaluationRule + ReadableV2EvaluationRule Examples -------- diff --git a/langfuse/api/unstable/evaluation_rules/raw_client.py b/langfuse/api/unstable/evaluation_rules/raw_client.py index 2933d87ac..4f531d118 100644 --- a/langfuse/api/unstable/evaluation_rules/raw_client.py +++ b/langfuse/api/unstable/evaluation_rules/raw_client.py @@ -54,6 +54,7 @@ from .types.evaluation_rule_evaluator_reference import EvaluationRuleEvaluatorReference from .types.evaluation_rules import EvaluationRules from .types.readable_evaluation_rule import ReadableEvaluationRule +from .types.readable_v2evaluation_rule import ReadableV2EvaluationRule # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -702,7 +703,7 @@ def update( filter: typing.Optional[typing.Sequence[EvaluationRuleFilter]] = OMIT, mapping: typing.Optional[typing.Sequence[PromptVariableMappingInput]] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[EvaluationRule]: + ) -> HttpResponse[ReadableV2EvaluationRule]: """ Update an evaluation rule. @@ -770,7 +771,7 @@ def update( Returns ------- - HttpResponse[EvaluationRule] + HttpResponse[ReadableV2EvaluationRule] """ _response = self._client_wrapper.httpx_client.request( f"api/public/unstable/evaluation-rules/{jsonable_encoder(evaluation_rule_id)}", @@ -807,9 +808,9 @@ def update( try: if 200 <= _response.status_code < 300: _data = typing.cast( - EvaluationRule, + ReadableV2EvaluationRule, parse_obj_as( - type_=EvaluationRule, # type: ignore + type_=ReadableV2EvaluationRule, # type: ignore object_=_response.json(), ), ) @@ -1801,7 +1802,7 @@ async def update( filter: typing.Optional[typing.Sequence[EvaluationRuleFilter]] = OMIT, mapping: typing.Optional[typing.Sequence[PromptVariableMappingInput]] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[EvaluationRule]: + ) -> AsyncHttpResponse[ReadableV2EvaluationRule]: """ Update an evaluation rule. @@ -1869,7 +1870,7 @@ async def update( Returns ------- - AsyncHttpResponse[EvaluationRule] + AsyncHttpResponse[ReadableV2EvaluationRule] """ _response = await self._client_wrapper.httpx_client.request( f"api/public/unstable/evaluation-rules/{jsonable_encoder(evaluation_rule_id)}", @@ -1906,9 +1907,9 @@ async def update( try: if 200 <= _response.status_code < 300: _data = typing.cast( - EvaluationRule, + ReadableV2EvaluationRule, parse_obj_as( - type_=EvaluationRule, # type: ignore + type_=ReadableV2EvaluationRule, # type: ignore object_=_response.json(), ), ) diff --git a/langfuse/api/unstable/evaluation_rules/types/__init__.py b/langfuse/api/unstable/evaluation_rules/types/__init__.py index d45705039..2540c08f5 100644 --- a/langfuse/api/unstable/evaluation_rules/types/__init__.py +++ b/langfuse/api/unstable/evaluation_rules/types/__init__.py @@ -43,6 +43,7 @@ ) from .llm_as_judge_evaluator_type import LlmAsJudgeEvaluatorType from .readable_evaluation_rule import ReadableEvaluationRule + from .readable_v2evaluation_rule import ReadableV2EvaluationRule from .update_evaluation_rule_request import UpdateEvaluationRuleRequest _dynamic_imports: typing.Dict[str, str] = { "CodeEvaluationRuleEvaluatorReference": ".code_evaluation_rule_evaluator_reference", @@ -68,6 +69,7 @@ "LlmAsJudgeEvaluationRuleEvaluatorReference": ".llm_as_judge_evaluation_rule_evaluator_reference", "LlmAsJudgeEvaluatorType": ".llm_as_judge_evaluator_type", "ReadableEvaluationRule": ".readable_evaluation_rule", + "ReadableV2EvaluationRule": ".readable_v2evaluation_rule", "UpdateEvaluationRuleRequest": ".update_evaluation_rule_request", } @@ -123,5 +125,6 @@ def __dir__(): "LlmAsJudgeEvaluationRuleEvaluatorReference", "LlmAsJudgeEvaluatorType", "ReadableEvaluationRule", + "ReadableV2EvaluationRule", "UpdateEvaluationRuleRequest", ] diff --git a/langfuse/api/unstable/evaluation_rules/types/evaluation_rule.py b/langfuse/api/unstable/evaluation_rules/types/evaluation_rule.py index 7d48501f3..653e163dc 100644 --- a/langfuse/api/unstable/evaluation_rules/types/evaluation_rule.py +++ b/langfuse/api/unstable/evaluation_rules/types/evaluation_rule.py @@ -11,83 +11,6 @@ class EvaluationRule(EvaluationRuleBase): - """ - Examples - -------- - import datetime - - from langfuse.unstable.commons import ( - EvaluationRuleFilter_StringOptions, - EvaluationRuleOptionsFilterOperator, - EvaluationRuleStatus, - EvaluationRuleTarget, - EvaluatorType, - PromptVariableMappingRead, - PromptVariableMappingSource, - ) - from langfuse.unstable.evaluation_rules import ( - EvaluationRule, - EvaluationRuleEvaluator, - EvaluationRuleEvaluatorAssignment, - ) - - EvaluationRule( - id="erule_123", - name="answer-correctness-live", - evaluator=EvaluationRuleEvaluator( - id="evaltmpl_123", - name="answer-correctness", - type=EvaluatorType.LLM_AS_JUDGE, - ), - evaluators=[ - EvaluationRuleEvaluatorAssignment( - evaluator=EvaluationRuleEvaluator( - id="evaltmpl_123", - name="answer-correctness", - type=EvaluatorType.LLM_AS_JUDGE, - ), - mapping=[ - PromptVariableMappingRead( - variable="input", - source=PromptVariableMappingSource.INPUT, - ), - PromptVariableMappingRead( - variable="output", - source=PromptVariableMappingSource.OUTPUT, - ), - ], - ) - ], - target=EvaluationRuleTarget.OBSERVATION, - enabled=True, - status=EvaluationRuleStatus.ACTIVE, - sampling=1.0, - filter=[ - EvaluationRuleFilter_StringOptions( - column="type", - operator=EvaluationRuleOptionsFilterOperator.ANY_OF, - value=["GENERATION"], - ) - ], - mapping=[ - PromptVariableMappingRead( - variable="input", - source=PromptVariableMappingSource.INPUT, - ), - PromptVariableMappingRead( - variable="output", - source=PromptVariableMappingSource.OUTPUT, - ), - ], - created_at=datetime.datetime.fromisoformat( - "2026-03-30 09:20:00+00:00", - ), - updated_at=datetime.datetime.fromisoformat( - "2026-03-30 09:20:00+00:00", - ), - ) - """ - evaluators: typing.List[EvaluationRuleEvaluatorAssignment] = pydantic.Field() """ Evaluators attached to this rule in deterministic assignment order. A `null` mapping inherits the evaluator version's default mapping. diff --git a/langfuse/api/unstable/evaluation_rules/types/readable_evaluation_rule.py b/langfuse/api/unstable/evaluation_rules/types/readable_evaluation_rule.py index b7eb2ccd0..f4eba5936 100644 --- a/langfuse/api/unstable/evaluation_rules/types/readable_evaluation_rule.py +++ b/langfuse/api/unstable/evaluation_rules/types/readable_evaluation_rule.py @@ -2,7 +2,7 @@ import typing -from .evaluation_rule import EvaluationRule from .legacy_evaluation_rule import LegacyEvaluationRule +from .readable_v2evaluation_rule import ReadableV2EvaluationRule -ReadableEvaluationRule = typing.Union[EvaluationRule, LegacyEvaluationRule] +ReadableEvaluationRule = typing.Union[ReadableV2EvaluationRule, LegacyEvaluationRule] diff --git a/langfuse/api/unstable/evaluation_rules/types/readable_v2evaluation_rule.py b/langfuse/api/unstable/evaluation_rules/types/readable_v2evaluation_rule.py new file mode 100644 index 000000000..2f9fe6ffa --- /dev/null +++ b/langfuse/api/unstable/evaluation_rules/types/readable_v2evaluation_rule.py @@ -0,0 +1,115 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ....evaluation_commons.types.evaluation_rule_read_filter import ( + EvaluationRuleReadFilter, +) +from ...commons.types.evaluation_rule_target import EvaluationRuleTarget +from ...commons.types.prompt_variable_mapping_read import PromptVariableMappingRead +from .evaluation_rule_base import EvaluationRuleBase +from .evaluation_rule_evaluator_assignment import EvaluationRuleEvaluatorAssignment + + +class ReadableV2EvaluationRule(EvaluationRuleBase): + """ + Examples + -------- + import datetime + + from langfuse.evaluation_commons import EvaluationRuleReadFilterBase + from langfuse.unstable.commons import ( + EvaluationRuleStatus, + EvaluationRuleTarget, + EvaluatorType, + PromptVariableMappingRead, + PromptVariableMappingSource, + ) + from langfuse.unstable.evaluation_rules import ( + EvaluationRuleEvaluator, + EvaluationRuleEvaluatorAssignment, + ReadableV2EvaluationRule, + ) + + ReadableV2EvaluationRule( + id="erule_123", + name="answer-correctness-live", + evaluator=EvaluationRuleEvaluator( + id="evaltmpl_123", + name="answer-correctness", + type=EvaluatorType.LLM_AS_JUDGE, + ), + evaluators=[ + EvaluationRuleEvaluatorAssignment( + evaluator=EvaluationRuleEvaluator( + id="evaltmpl_123", + name="answer-correctness", + type=EvaluatorType.LLM_AS_JUDGE, + ), + mapping=[ + PromptVariableMappingRead( + variable="input", + source=PromptVariableMappingSource.INPUT, + ), + PromptVariableMappingRead( + variable="output", + source=PromptVariableMappingSource.OUTPUT, + ), + ], + ) + ], + target=EvaluationRuleTarget.OBSERVATION, + enabled=True, + status=EvaluationRuleStatus.ACTIVE, + sampling=1.0, + filter=[ + EvaluationRuleReadFilterBase( + type="stringOptions", + column="type", + operator="any of", + value=["GENERATION"], + ) + ], + mapping=[ + PromptVariableMappingRead( + variable="input", + source=PromptVariableMappingSource.INPUT, + ), + PromptVariableMappingRead( + variable="output", + source=PromptVariableMappingSource.OUTPUT, + ), + ], + created_at=datetime.datetime.fromisoformat( + "2026-03-30 09:20:00+00:00", + ), + updated_at=datetime.datetime.fromisoformat( + "2026-03-30 09:20:00+00:00", + ), + ) + """ + + evaluators: typing.List[EvaluationRuleEvaluatorAssignment] = pydantic.Field() + """ + Evaluators attached to this rule in deterministic assignment order. A `null` mapping inherits the evaluator version's default mapping. + """ + + target: EvaluationRuleTarget = pydantic.Field() + """ + Target object type that should trigger scoring. + """ + + filter: typing.List[EvaluationRuleReadFilter] = pydantic.Field() + """ + List of stored filter conditions returned verbatim. Historical filters remain readable even when the current write contract no longer accepts their shape. + """ + + mapping: typing.List[PromptVariableMappingRead] = pydantic.Field() + """ + Deprecated compatibility alias containing the effective mapping for `evaluators[0]`. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + )