From 4e8045f15693fd7440906bd3d1cef95553927e24 Mon Sep 17 00:00:00 2001 From: langfuse-bot Date: Tue, 9 Jun 2026 07:32:25 +0000 Subject: [PATCH] feat(api): update API spec from langfuse/langfuse d32b852 --- langfuse/api/__init__.py | 74 +++ langfuse/api/client.py | 19 + langfuse/api/scores_v3/__init__.py | 112 +++++ langfuse/api/scores_v3/client.py | 341 +++++++++++++ langfuse/api/scores_v3/raw_client.py | 460 ++++++++++++++++++ langfuse/api/scores_v3/types/__init__.py | 114 +++++ langfuse/api/scores_v3/types/base_score_v3.py | 71 +++ .../api/scores_v3/types/boolean_score_v3.py | 17 + .../scores_v3/types/categorical_score_v3.py | 17 + .../scores_v3/types/correction_score_v3.py | 17 + .../api/scores_v3/types/get_scores_v3meta.py | 18 + .../scores_v3/types/get_scores_v3response.py | 17 + .../api/scores_v3/types/numeric_score_v3.py | 17 + .../types/score_subject_experiment_v3.py | 17 + .../types/score_subject_observation_v3.py | 26 + .../types/score_subject_session_v3.py | 17 + .../scores_v3/types/score_subject_trace_v3.py | 17 + .../api/scores_v3/types/score_subject_v3.py | 76 +++ langfuse/api/scores_v3/types/score_v3.py | 200 ++++++++ langfuse/api/scores_v3/types/text_score_v3.py | 17 + 20 files changed, 1664 insertions(+) create mode 100644 langfuse/api/scores_v3/__init__.py create mode 100644 langfuse/api/scores_v3/client.py create mode 100644 langfuse/api/scores_v3/raw_client.py create mode 100644 langfuse/api/scores_v3/types/__init__.py create mode 100644 langfuse/api/scores_v3/types/base_score_v3.py create mode 100644 langfuse/api/scores_v3/types/boolean_score_v3.py create mode 100644 langfuse/api/scores_v3/types/categorical_score_v3.py create mode 100644 langfuse/api/scores_v3/types/correction_score_v3.py create mode 100644 langfuse/api/scores_v3/types/get_scores_v3meta.py create mode 100644 langfuse/api/scores_v3/types/get_scores_v3response.py create mode 100644 langfuse/api/scores_v3/types/numeric_score_v3.py create mode 100644 langfuse/api/scores_v3/types/score_subject_experiment_v3.py create mode 100644 langfuse/api/scores_v3/types/score_subject_observation_v3.py create mode 100644 langfuse/api/scores_v3/types/score_subject_session_v3.py create mode 100644 langfuse/api/scores_v3/types/score_subject_trace_v3.py create mode 100644 langfuse/api/scores_v3/types/score_subject_v3.py create mode 100644 langfuse/api/scores_v3/types/score_v3.py create mode 100644 langfuse/api/scores_v3/types/text_score_v3.py diff --git a/langfuse/api/__init__.py b/langfuse/api/__init__.py index 0e036263a..46985c0b9 100644 --- a/langfuse/api/__init__.py +++ b/langfuse/api/__init__.py @@ -30,6 +30,7 @@ scim, score_configs, scores, + scores_v3, sessions, trace, unstable, @@ -297,6 +298,31 @@ GetScoresResponseData_Text, GetScoresResponseTraceData, ) + from .scores_v3 import ( + BaseScoreV3, + BooleanScoreV3, + CategoricalScoreV3, + CorrectionScoreV3, + GetScoresV3Meta, + GetScoresV3Response, + NumericScoreV3, + ScoreSubjectExperimentV3, + ScoreSubjectObservationV3, + ScoreSubjectSessionV3, + ScoreSubjectTraceV3, + ScoreSubjectV3, + ScoreSubjectV3_Experiment, + ScoreSubjectV3_Observation, + ScoreSubjectV3_Session, + ScoreSubjectV3_Trace, + ScoreV3, + ScoreV3_Boolean, + ScoreV3_Categorical, + ScoreV3_Correction, + ScoreV3_Numeric, + ScoreV3_Text, + TextScoreV3, + ) from .sessions import PaginatedSessions from .trace import DeleteTraceResponse, Sort, Traces _dynamic_imports: typing.Dict[str, str] = { @@ -316,6 +342,7 @@ "BasePrompt": ".prompts", "BaseScore": ".commons", "BaseScoreV1": ".commons", + "BaseScoreV3": ".scores_v3", "BlobStorageExportFieldGroup": ".blob_storage_integrations", "BlobStorageExportFrequency": ".blob_storage_integrations", "BlobStorageExportMode": ".blob_storage_integrations", @@ -329,9 +356,11 @@ "BlobStorageSyncStatus": ".blob_storage_integrations", "BooleanScore": ".commons", "BooleanScoreV1": ".commons", + "BooleanScoreV3": ".scores_v3", "BulkConfig": ".scim", "CategoricalScore": ".commons", "CategoricalScoreV1": ".commons", + "CategoricalScoreV3": ".scores_v3", "ChatMessage": ".prompts", "ChatMessageType": ".prompts", "ChatMessageWithPlaceholders": ".prompts", @@ -340,6 +369,7 @@ "CommentObjectType": ".commons", "ConfigCategory": ".commons", "CorrectionScore": ".commons", + "CorrectionScoreV3": ".scores_v3", "CreateAnnotationQueueAssignmentResponse": ".annotation_queues", "CreateAnnotationQueueItemRequest": ".annotation_queues", "CreateAnnotationQueueRequest": ".annotation_queues", @@ -397,6 +427,8 @@ "GetScoresResponseData_Numeric": ".scores", "GetScoresResponseData_Text": ".scores", "GetScoresResponseTraceData": ".scores", + "GetScoresV3Meta": ".scores_v3", + "GetScoresV3Response": ".scores_v3", "HealthResponse": ".health", "IngestionError": ".ingestion", "IngestionEvent": ".ingestion", @@ -431,6 +463,7 @@ "NotFoundError": ".commons", "NumericScore": ".commons", "NumericScoreV1": ".commons", + "NumericScoreV3": ".scores_v3", "Observation": ".commons", "ObservationBody": ".ingestion", "ObservationLevel": ".commons", @@ -500,11 +533,26 @@ "ScoreDataType": ".commons", "ScoreEvent": ".ingestion", "ScoreSource": ".commons", + "ScoreSubjectExperimentV3": ".scores_v3", + "ScoreSubjectObservationV3": ".scores_v3", + "ScoreSubjectSessionV3": ".scores_v3", + "ScoreSubjectTraceV3": ".scores_v3", + "ScoreSubjectV3": ".scores_v3", + "ScoreSubjectV3_Experiment": ".scores_v3", + "ScoreSubjectV3_Observation": ".scores_v3", + "ScoreSubjectV3_Session": ".scores_v3", + "ScoreSubjectV3_Trace": ".scores_v3", "ScoreV1": ".commons", "ScoreV1_Boolean": ".commons", "ScoreV1_Categorical": ".commons", "ScoreV1_Numeric": ".commons", "ScoreV1_Text": ".commons", + "ScoreV3": ".scores_v3", + "ScoreV3_Boolean": ".scores_v3", + "ScoreV3_Categorical": ".scores_v3", + "ScoreV3_Correction": ".scores_v3", + "ScoreV3_Numeric": ".scores_v3", + "ScoreV3_Text": ".scores_v3", "Score_Boolean": ".commons", "Score_Categorical": ".commons", "Score_Correction": ".commons", @@ -520,6 +568,7 @@ "TextPrompt": ".prompts", "TextScore": ".commons", "TextScoreV1": ".commons", + "TextScoreV3": ".scores_v3", "Trace": ".commons", "TraceBody": ".ingestion", "TraceEvent": ".ingestion", @@ -562,6 +611,7 @@ "scim": ".scim", "score_configs": ".score_configs", "scores": ".scores", + "scores_v3": ".scores_v3", "sessions": ".sessions", "trace": ".trace", "unstable": ".unstable", @@ -613,6 +663,7 @@ def __dir__(): "BasePrompt", "BaseScore", "BaseScoreV1", + "BaseScoreV3", "BlobStorageExportFieldGroup", "BlobStorageExportFrequency", "BlobStorageExportMode", @@ -626,9 +677,11 @@ def __dir__(): "BlobStorageSyncStatus", "BooleanScore", "BooleanScoreV1", + "BooleanScoreV3", "BulkConfig", "CategoricalScore", "CategoricalScoreV1", + "CategoricalScoreV3", "ChatMessage", "ChatMessageType", "ChatMessageWithPlaceholders", @@ -637,6 +690,7 @@ def __dir__(): "CommentObjectType", "ConfigCategory", "CorrectionScore", + "CorrectionScoreV3", "CreateAnnotationQueueAssignmentResponse", "CreateAnnotationQueueItemRequest", "CreateAnnotationQueueRequest", @@ -694,6 +748,8 @@ def __dir__(): "GetScoresResponseData_Numeric", "GetScoresResponseData_Text", "GetScoresResponseTraceData", + "GetScoresV3Meta", + "GetScoresV3Response", "HealthResponse", "IngestionError", "IngestionEvent", @@ -728,6 +784,7 @@ def __dir__(): "NotFoundError", "NumericScore", "NumericScoreV1", + "NumericScoreV3", "Observation", "ObservationBody", "ObservationLevel", @@ -797,11 +854,26 @@ def __dir__(): "ScoreDataType", "ScoreEvent", "ScoreSource", + "ScoreSubjectExperimentV3", + "ScoreSubjectObservationV3", + "ScoreSubjectSessionV3", + "ScoreSubjectTraceV3", + "ScoreSubjectV3", + "ScoreSubjectV3_Experiment", + "ScoreSubjectV3_Observation", + "ScoreSubjectV3_Session", + "ScoreSubjectV3_Trace", "ScoreV1", "ScoreV1_Boolean", "ScoreV1_Categorical", "ScoreV1_Numeric", "ScoreV1_Text", + "ScoreV3", + "ScoreV3_Boolean", + "ScoreV3_Categorical", + "ScoreV3_Correction", + "ScoreV3_Numeric", + "ScoreV3_Text", "Score_Boolean", "Score_Categorical", "Score_Correction", @@ -817,6 +889,7 @@ def __dir__(): "TextPrompt", "TextScore", "TextScoreV1", + "TextScoreV3", "Trace", "TraceBody", "TraceEvent", @@ -859,6 +932,7 @@ def __dir__(): "scim", "score_configs", "scores", + "scores_v3", "sessions", "trace", "unstable", diff --git a/langfuse/api/client.py b/langfuse/api/client.py index c0413704b..a72aede85 100644 --- a/langfuse/api/client.py +++ b/langfuse/api/client.py @@ -39,6 +39,7 @@ from .scim.client import AsyncScimClient, ScimClient from .score_configs.client import AsyncScoreConfigsClient, ScoreConfigsClient from .scores.client import AsyncScoresClient, ScoresClient + from .scores_v3.client import AsyncScoresV3Client, ScoresV3Client from .sessions.client import AsyncSessionsClient, SessionsClient from .trace.client import AsyncTraceClient, TraceClient from .unstable.client import AsyncUnstableClient, UnstableClient @@ -145,6 +146,7 @@ def __init__( self._prompts: typing.Optional[PromptsClient] = None self._scim: typing.Optional[ScimClient] = None self._score_configs: typing.Optional[ScoreConfigsClient] = None + self._scores_v3: typing.Optional[ScoresV3Client] = None self._scores: typing.Optional[ScoresClient] = None self._sessions: typing.Optional[SessionsClient] = None self._trace: typing.Optional[TraceClient] = None @@ -336,6 +338,14 @@ def score_configs(self): ) return self._score_configs + @property + def scores_v3(self): + if self._scores_v3 is None: + from .scores_v3.client import ScoresV3Client # noqa: E402 + + self._scores_v3 = ScoresV3Client(client_wrapper=self._client_wrapper) + return self._scores_v3 + @property def scores(self): if self._scores is None: @@ -470,6 +480,7 @@ def __init__( self._prompts: typing.Optional[AsyncPromptsClient] = None self._scim: typing.Optional[AsyncScimClient] = None self._score_configs: typing.Optional[AsyncScoreConfigsClient] = None + self._scores_v3: typing.Optional[AsyncScoresV3Client] = None self._scores: typing.Optional[AsyncScoresClient] = None self._sessions: typing.Optional[AsyncSessionsClient] = None self._trace: typing.Optional[AsyncTraceClient] = None @@ -665,6 +676,14 @@ def score_configs(self): ) return self._score_configs + @property + def scores_v3(self): + if self._scores_v3 is None: + from .scores_v3.client import AsyncScoresV3Client # noqa: E402 + + self._scores_v3 = AsyncScoresV3Client(client_wrapper=self._client_wrapper) + return self._scores_v3 + @property def scores(self): if self._scores is None: diff --git a/langfuse/api/scores_v3/__init__.py b/langfuse/api/scores_v3/__init__.py new file mode 100644 index 000000000..855868335 --- /dev/null +++ b/langfuse/api/scores_v3/__init__.py @@ -0,0 +1,112 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from .types import ( + BaseScoreV3, + BooleanScoreV3, + CategoricalScoreV3, + CorrectionScoreV3, + GetScoresV3Meta, + GetScoresV3Response, + NumericScoreV3, + ScoreSubjectExperimentV3, + ScoreSubjectObservationV3, + ScoreSubjectSessionV3, + ScoreSubjectTraceV3, + ScoreSubjectV3, + ScoreSubjectV3_Experiment, + ScoreSubjectV3_Observation, + ScoreSubjectV3_Session, + ScoreSubjectV3_Trace, + ScoreV3, + ScoreV3_Boolean, + ScoreV3_Categorical, + ScoreV3_Correction, + ScoreV3_Numeric, + ScoreV3_Text, + TextScoreV3, + ) +_dynamic_imports: typing.Dict[str, str] = { + "BaseScoreV3": ".types", + "BooleanScoreV3": ".types", + "CategoricalScoreV3": ".types", + "CorrectionScoreV3": ".types", + "GetScoresV3Meta": ".types", + "GetScoresV3Response": ".types", + "NumericScoreV3": ".types", + "ScoreSubjectExperimentV3": ".types", + "ScoreSubjectObservationV3": ".types", + "ScoreSubjectSessionV3": ".types", + "ScoreSubjectTraceV3": ".types", + "ScoreSubjectV3": ".types", + "ScoreSubjectV3_Experiment": ".types", + "ScoreSubjectV3_Observation": ".types", + "ScoreSubjectV3_Session": ".types", + "ScoreSubjectV3_Trace": ".types", + "ScoreV3": ".types", + "ScoreV3_Boolean": ".types", + "ScoreV3_Categorical": ".types", + "ScoreV3_Correction": ".types", + "ScoreV3_Numeric": ".types", + "ScoreV3_Text": ".types", + "TextScoreV3": ".types", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError( + f"No {attr_name} found in _dynamic_imports for module name -> {__name__}" + ) + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError( + f"Failed to import {attr_name} from {module_name}: {e}" + ) from e + except AttributeError as e: + raise AttributeError( + f"Failed to get {attr_name} from {module_name}: {e}" + ) from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + + +__all__ = [ + "BaseScoreV3", + "BooleanScoreV3", + "CategoricalScoreV3", + "CorrectionScoreV3", + "GetScoresV3Meta", + "GetScoresV3Response", + "NumericScoreV3", + "ScoreSubjectExperimentV3", + "ScoreSubjectObservationV3", + "ScoreSubjectSessionV3", + "ScoreSubjectTraceV3", + "ScoreSubjectV3", + "ScoreSubjectV3_Experiment", + "ScoreSubjectV3_Observation", + "ScoreSubjectV3_Session", + "ScoreSubjectV3_Trace", + "ScoreV3", + "ScoreV3_Boolean", + "ScoreV3_Categorical", + "ScoreV3_Correction", + "ScoreV3_Numeric", + "ScoreV3_Text", + "TextScoreV3", +] diff --git a/langfuse/api/scores_v3/client.py b/langfuse/api/scores_v3/client.py new file mode 100644 index 000000000..2755d3e74 --- /dev/null +++ b/langfuse/api/scores_v3/client.py @@ -0,0 +1,341 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.request_options import RequestOptions +from .raw_client import AsyncRawScoresV3Client, RawScoresV3Client +from .types.get_scores_v3response import GetScoresV3Response + + +class ScoresV3Client: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._raw_client = RawScoresV3Client(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> RawScoresV3Client: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + RawScoresV3Client + """ + return self._raw_client + + def get_many_v3( + self, + *, + limit: typing.Optional[int] = None, + cursor: typing.Optional[str] = None, + fields: typing.Optional[str] = None, + id: typing.Optional[str] = None, + name: typing.Optional[str] = None, + source: typing.Optional[str] = None, + data_type: typing.Optional[str] = None, + environment: typing.Optional[str] = None, + config_id: typing.Optional[str] = None, + queue_id: typing.Optional[str] = None, + author_user_id: typing.Optional[str] = None, + value: typing.Optional[str] = None, + value_min: typing.Optional[float] = None, + value_max: typing.Optional[float] = None, + trace_id: typing.Optional[str] = None, + session_id: typing.Optional[str] = None, + observation_id: typing.Optional[str] = None, + experiment_id: typing.Optional[str] = None, + from_timestamp: typing.Optional[dt.datetime] = None, + to_timestamp: typing.Optional[dt.datetime] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetScoresV3Response: + """ + Get a list of scores with a polymorphic `value` field (v3). + + This endpoint requires Langfuse v4 or later. + + The `value` field type depends on `dataType`: + - `NUMERIC` → number + - `BOOLEAN` → boolean + - `CATEGORICAL`, `TEXT`, `CORRECTION` → string + + Use the `fields` parameter to include optional field groups beyond the + default `core`. Unknown group names return HTTP 400. + + Parameters + ---------- + limit : typing.Optional[int] + Number of items per page. Maximum 100, default 50. Requests with a limit greater than 100 return HTTP 400. + + cursor : typing.Optional[str] + URL-safe base64 (base64url) cursor for pagination. Use the cursor from the previous response to get the next page. Absent on the final page. + + fields : typing.Optional[str] + Comma-separated field groups to include. Allowed: core, details, subject, annotation. Defaults to "core". Unknown names return HTTP 400. + + id : typing.Optional[str] + Comma-separated list of score IDs to filter by (OR within, AND across filters). + + name : typing.Optional[str] + Comma-separated list of score names to filter by. + + source : typing.Optional[str] + Comma-separated list of score sources to filter by (e.g. API, ANNOTATION, EVAL). Case-insensitive — `api` and `API` are equivalent. + + data_type : typing.Optional[str] + Comma-separated list of data types to filter by (NUMERIC, BOOLEAN, CATEGORICAL, TEXT, CORRECTION). Case-insensitive — `numeric` and `NUMERIC` are equivalent. Must be a single value when used with value, valueMin, or valueMax; otherwise the request returns HTTP 400. Must be NUMERIC when used with valueMin or valueMax. + + environment : typing.Optional[str] + Comma-separated list of environments to filter by. + + config_id : typing.Optional[str] + Comma-separated list of score config IDs to filter by. + + queue_id : typing.Optional[str] + Comma-separated list of annotation queue IDs to filter by. + + author_user_id : typing.Optional[str] + Comma-separated list of author user IDs to filter by. + + value : typing.Optional[str] + Comma-separated list of exact values to filter by. Requires a single dataType from NUMERIC, BOOLEAN, or CATEGORICAL; any other dataType, multiple dataTypes, or omitting dataType returns HTTP 400. For BOOLEAN, each value must be "true" or "false"; for NUMERIC, each value must be a finite number. Otherwise the request returns HTTP 400. + + value_min : typing.Optional[float] + Inclusive lower bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400. + + value_max : typing.Optional[float] + Inclusive upper bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400. + + trace_id : typing.Optional[str] + Comma-separated list of trace IDs to filter by. Mutually exclusive with sessionId, experimentId. May be combined with observationId to scope the observation lookup to a specific trace. + + session_id : typing.Optional[str] + Comma-separated list of session IDs to filter by. Mutually exclusive with traceId, observationId, experimentId. + + observation_id : typing.Optional[str] + Comma-separated list of observation IDs to filter by. Requires traceId to be specified, because observation IDs are scoped to a trace. Mutually exclusive with sessionId, experimentId. Returns HTTP 400 when used without traceId. + + experiment_id : typing.Optional[str] + Comma-separated list of dataset run IDs (experiment IDs) to filter by. Mutually exclusive with traceId, sessionId, observationId. + + from_timestamp : typing.Optional[dt.datetime] + Inclusive lower bound on the score timestamp. + + to_timestamp : typing.Optional[dt.datetime] + Exclusive upper bound on the score timestamp. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetScoresV3Response + + Examples + -------- + from langfuse import LangfuseAPI + + client = LangfuseAPI( + x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", + x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", + x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", + username="YOUR_USERNAME", + password="YOUR_PASSWORD", + base_url="https://yourhost.com/path/to/api", + ) + client.scores_v3.get_many_v3() + """ + _response = self._raw_client.get_many_v3( + limit=limit, + cursor=cursor, + fields=fields, + id=id, + name=name, + source=source, + data_type=data_type, + environment=environment, + config_id=config_id, + queue_id=queue_id, + author_user_id=author_user_id, + value=value, + value_min=value_min, + value_max=value_max, + trace_id=trace_id, + session_id=session_id, + observation_id=observation_id, + experiment_id=experiment_id, + from_timestamp=from_timestamp, + to_timestamp=to_timestamp, + request_options=request_options, + ) + return _response.data + + +class AsyncScoresV3Client: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._raw_client = AsyncRawScoresV3Client(client_wrapper=client_wrapper) + + @property + def with_raw_response(self) -> AsyncRawScoresV3Client: + """ + Retrieves a raw implementation of this client that returns raw responses. + + Returns + ------- + AsyncRawScoresV3Client + """ + return self._raw_client + + async def get_many_v3( + self, + *, + limit: typing.Optional[int] = None, + cursor: typing.Optional[str] = None, + fields: typing.Optional[str] = None, + id: typing.Optional[str] = None, + name: typing.Optional[str] = None, + source: typing.Optional[str] = None, + data_type: typing.Optional[str] = None, + environment: typing.Optional[str] = None, + config_id: typing.Optional[str] = None, + queue_id: typing.Optional[str] = None, + author_user_id: typing.Optional[str] = None, + value: typing.Optional[str] = None, + value_min: typing.Optional[float] = None, + value_max: typing.Optional[float] = None, + trace_id: typing.Optional[str] = None, + session_id: typing.Optional[str] = None, + observation_id: typing.Optional[str] = None, + experiment_id: typing.Optional[str] = None, + from_timestamp: typing.Optional[dt.datetime] = None, + to_timestamp: typing.Optional[dt.datetime] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetScoresV3Response: + """ + Get a list of scores with a polymorphic `value` field (v3). + + This endpoint requires Langfuse v4 or later. + + The `value` field type depends on `dataType`: + - `NUMERIC` → number + - `BOOLEAN` → boolean + - `CATEGORICAL`, `TEXT`, `CORRECTION` → string + + Use the `fields` parameter to include optional field groups beyond the + default `core`. Unknown group names return HTTP 400. + + Parameters + ---------- + limit : typing.Optional[int] + Number of items per page. Maximum 100, default 50. Requests with a limit greater than 100 return HTTP 400. + + cursor : typing.Optional[str] + URL-safe base64 (base64url) cursor for pagination. Use the cursor from the previous response to get the next page. Absent on the final page. + + fields : typing.Optional[str] + Comma-separated field groups to include. Allowed: core, details, subject, annotation. Defaults to "core". Unknown names return HTTP 400. + + id : typing.Optional[str] + Comma-separated list of score IDs to filter by (OR within, AND across filters). + + name : typing.Optional[str] + Comma-separated list of score names to filter by. + + source : typing.Optional[str] + Comma-separated list of score sources to filter by (e.g. API, ANNOTATION, EVAL). Case-insensitive — `api` and `API` are equivalent. + + data_type : typing.Optional[str] + Comma-separated list of data types to filter by (NUMERIC, BOOLEAN, CATEGORICAL, TEXT, CORRECTION). Case-insensitive — `numeric` and `NUMERIC` are equivalent. Must be a single value when used with value, valueMin, or valueMax; otherwise the request returns HTTP 400. Must be NUMERIC when used with valueMin or valueMax. + + environment : typing.Optional[str] + Comma-separated list of environments to filter by. + + config_id : typing.Optional[str] + Comma-separated list of score config IDs to filter by. + + queue_id : typing.Optional[str] + Comma-separated list of annotation queue IDs to filter by. + + author_user_id : typing.Optional[str] + Comma-separated list of author user IDs to filter by. + + value : typing.Optional[str] + Comma-separated list of exact values to filter by. Requires a single dataType from NUMERIC, BOOLEAN, or CATEGORICAL; any other dataType, multiple dataTypes, or omitting dataType returns HTTP 400. For BOOLEAN, each value must be "true" or "false"; for NUMERIC, each value must be a finite number. Otherwise the request returns HTTP 400. + + value_min : typing.Optional[float] + Inclusive lower bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400. + + value_max : typing.Optional[float] + Inclusive upper bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400. + + trace_id : typing.Optional[str] + Comma-separated list of trace IDs to filter by. Mutually exclusive with sessionId, experimentId. May be combined with observationId to scope the observation lookup to a specific trace. + + session_id : typing.Optional[str] + Comma-separated list of session IDs to filter by. Mutually exclusive with traceId, observationId, experimentId. + + observation_id : typing.Optional[str] + Comma-separated list of observation IDs to filter by. Requires traceId to be specified, because observation IDs are scoped to a trace. Mutually exclusive with sessionId, experimentId. Returns HTTP 400 when used without traceId. + + experiment_id : typing.Optional[str] + Comma-separated list of dataset run IDs (experiment IDs) to filter by. Mutually exclusive with traceId, sessionId, observationId. + + from_timestamp : typing.Optional[dt.datetime] + Inclusive lower bound on the score timestamp. + + to_timestamp : typing.Optional[dt.datetime] + Exclusive upper bound on the score timestamp. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetScoresV3Response + + Examples + -------- + import asyncio + + from langfuse import AsyncLangfuseAPI + + client = AsyncLangfuseAPI( + x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", + x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", + x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", + username="YOUR_USERNAME", + password="YOUR_PASSWORD", + base_url="https://yourhost.com/path/to/api", + ) + + + async def main() -> None: + await client.scores_v3.get_many_v3() + + + asyncio.run(main()) + """ + _response = await self._raw_client.get_many_v3( + limit=limit, + cursor=cursor, + fields=fields, + id=id, + name=name, + source=source, + data_type=data_type, + environment=environment, + config_id=config_id, + queue_id=queue_id, + author_user_id=author_user_id, + value=value, + value_min=value_min, + value_max=value_max, + trace_id=trace_id, + session_id=session_id, + observation_id=observation_id, + experiment_id=experiment_id, + from_timestamp=from_timestamp, + to_timestamp=to_timestamp, + request_options=request_options, + ) + return _response.data diff --git a/langfuse/api/scores_v3/raw_client.py b/langfuse/api/scores_v3/raw_client.py new file mode 100644 index 000000000..47c9f3f8d --- /dev/null +++ b/langfuse/api/scores_v3/raw_client.py @@ -0,0 +1,460 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing +from json.decoder import JSONDecodeError + +from ..commons.errors.access_denied_error import AccessDeniedError +from ..commons.errors.error import Error +from ..commons.errors.method_not_allowed_error import MethodNotAllowedError +from ..commons.errors.not_found_error import NotFoundError +from ..commons.errors.unauthorized_error import UnauthorizedError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.datetime_utils import serialize_datetime +from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.pydantic_utilities import parse_obj_as +from ..core.request_options import RequestOptions +from .types.get_scores_v3response import GetScoresV3Response + + +class RawScoresV3Client: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_many_v3( + self, + *, + limit: typing.Optional[int] = None, + cursor: typing.Optional[str] = None, + fields: typing.Optional[str] = None, + id: typing.Optional[str] = None, + name: typing.Optional[str] = None, + source: typing.Optional[str] = None, + data_type: typing.Optional[str] = None, + environment: typing.Optional[str] = None, + config_id: typing.Optional[str] = None, + queue_id: typing.Optional[str] = None, + author_user_id: typing.Optional[str] = None, + value: typing.Optional[str] = None, + value_min: typing.Optional[float] = None, + value_max: typing.Optional[float] = None, + trace_id: typing.Optional[str] = None, + session_id: typing.Optional[str] = None, + observation_id: typing.Optional[str] = None, + experiment_id: typing.Optional[str] = None, + from_timestamp: typing.Optional[dt.datetime] = None, + to_timestamp: typing.Optional[dt.datetime] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[GetScoresV3Response]: + """ + Get a list of scores with a polymorphic `value` field (v3). + + This endpoint requires Langfuse v4 or later. + + The `value` field type depends on `dataType`: + - `NUMERIC` → number + - `BOOLEAN` → boolean + - `CATEGORICAL`, `TEXT`, `CORRECTION` → string + + Use the `fields` parameter to include optional field groups beyond the + default `core`. Unknown group names return HTTP 400. + + Parameters + ---------- + limit : typing.Optional[int] + Number of items per page. Maximum 100, default 50. Requests with a limit greater than 100 return HTTP 400. + + cursor : typing.Optional[str] + URL-safe base64 (base64url) cursor for pagination. Use the cursor from the previous response to get the next page. Absent on the final page. + + fields : typing.Optional[str] + Comma-separated field groups to include. Allowed: core, details, subject, annotation. Defaults to "core". Unknown names return HTTP 400. + + id : typing.Optional[str] + Comma-separated list of score IDs to filter by (OR within, AND across filters). + + name : typing.Optional[str] + Comma-separated list of score names to filter by. + + source : typing.Optional[str] + Comma-separated list of score sources to filter by (e.g. API, ANNOTATION, EVAL). Case-insensitive — `api` and `API` are equivalent. + + data_type : typing.Optional[str] + Comma-separated list of data types to filter by (NUMERIC, BOOLEAN, CATEGORICAL, TEXT, CORRECTION). Case-insensitive — `numeric` and `NUMERIC` are equivalent. Must be a single value when used with value, valueMin, or valueMax; otherwise the request returns HTTP 400. Must be NUMERIC when used with valueMin or valueMax. + + environment : typing.Optional[str] + Comma-separated list of environments to filter by. + + config_id : typing.Optional[str] + Comma-separated list of score config IDs to filter by. + + queue_id : typing.Optional[str] + Comma-separated list of annotation queue IDs to filter by. + + author_user_id : typing.Optional[str] + Comma-separated list of author user IDs to filter by. + + value : typing.Optional[str] + Comma-separated list of exact values to filter by. Requires a single dataType from NUMERIC, BOOLEAN, or CATEGORICAL; any other dataType, multiple dataTypes, or omitting dataType returns HTTP 400. For BOOLEAN, each value must be "true" or "false"; for NUMERIC, each value must be a finite number. Otherwise the request returns HTTP 400. + + value_min : typing.Optional[float] + Inclusive lower bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400. + + value_max : typing.Optional[float] + Inclusive upper bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400. + + trace_id : typing.Optional[str] + Comma-separated list of trace IDs to filter by. Mutually exclusive with sessionId, experimentId. May be combined with observationId to scope the observation lookup to a specific trace. + + session_id : typing.Optional[str] + Comma-separated list of session IDs to filter by. Mutually exclusive with traceId, observationId, experimentId. + + observation_id : typing.Optional[str] + Comma-separated list of observation IDs to filter by. Requires traceId to be specified, because observation IDs are scoped to a trace. Mutually exclusive with sessionId, experimentId. Returns HTTP 400 when used without traceId. + + experiment_id : typing.Optional[str] + Comma-separated list of dataset run IDs (experiment IDs) to filter by. Mutually exclusive with traceId, sessionId, observationId. + + from_timestamp : typing.Optional[dt.datetime] + Inclusive lower bound on the score timestamp. + + to_timestamp : typing.Optional[dt.datetime] + Exclusive upper bound on the score timestamp. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[GetScoresV3Response] + """ + _response = self._client_wrapper.httpx_client.request( + "api/public/v3/scores", + method="GET", + params={ + "limit": limit, + "cursor": cursor, + "fields": fields, + "id": id, + "name": name, + "source": source, + "dataType": data_type, + "environment": environment, + "configId": config_id, + "queueId": queue_id, + "authorUserId": author_user_id, + "value": value, + "valueMin": value_min, + "valueMax": value_max, + "traceId": trace_id, + "sessionId": session_id, + "observationId": observation_id, + "experimentId": experiment_id, + "fromTimestamp": serialize_datetime(from_timestamp) + if from_timestamp is not None + else None, + "toTimestamp": serialize_datetime(to_timestamp) + if to_timestamp is not None + else None, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetScoresV3Response, + parse_obj_as( + type_=GetScoresV3Response, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise Error( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise AccessDeniedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 405: + raise MethodNotAllowedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, + headers=dict(_response.headers), + body=_response.text, + ) + raise ApiError( + status_code=_response.status_code, + headers=dict(_response.headers), + body=_response_json, + ) + + +class AsyncRawScoresV3Client: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_many_v3( + self, + *, + limit: typing.Optional[int] = None, + cursor: typing.Optional[str] = None, + fields: typing.Optional[str] = None, + id: typing.Optional[str] = None, + name: typing.Optional[str] = None, + source: typing.Optional[str] = None, + data_type: typing.Optional[str] = None, + environment: typing.Optional[str] = None, + config_id: typing.Optional[str] = None, + queue_id: typing.Optional[str] = None, + author_user_id: typing.Optional[str] = None, + value: typing.Optional[str] = None, + value_min: typing.Optional[float] = None, + value_max: typing.Optional[float] = None, + trace_id: typing.Optional[str] = None, + session_id: typing.Optional[str] = None, + observation_id: typing.Optional[str] = None, + experiment_id: typing.Optional[str] = None, + from_timestamp: typing.Optional[dt.datetime] = None, + to_timestamp: typing.Optional[dt.datetime] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[GetScoresV3Response]: + """ + Get a list of scores with a polymorphic `value` field (v3). + + This endpoint requires Langfuse v4 or later. + + The `value` field type depends on `dataType`: + - `NUMERIC` → number + - `BOOLEAN` → boolean + - `CATEGORICAL`, `TEXT`, `CORRECTION` → string + + Use the `fields` parameter to include optional field groups beyond the + default `core`. Unknown group names return HTTP 400. + + Parameters + ---------- + limit : typing.Optional[int] + Number of items per page. Maximum 100, default 50. Requests with a limit greater than 100 return HTTP 400. + + cursor : typing.Optional[str] + URL-safe base64 (base64url) cursor for pagination. Use the cursor from the previous response to get the next page. Absent on the final page. + + fields : typing.Optional[str] + Comma-separated field groups to include. Allowed: core, details, subject, annotation. Defaults to "core". Unknown names return HTTP 400. + + id : typing.Optional[str] + Comma-separated list of score IDs to filter by (OR within, AND across filters). + + name : typing.Optional[str] + Comma-separated list of score names to filter by. + + source : typing.Optional[str] + Comma-separated list of score sources to filter by (e.g. API, ANNOTATION, EVAL). Case-insensitive — `api` and `API` are equivalent. + + data_type : typing.Optional[str] + Comma-separated list of data types to filter by (NUMERIC, BOOLEAN, CATEGORICAL, TEXT, CORRECTION). Case-insensitive — `numeric` and `NUMERIC` are equivalent. Must be a single value when used with value, valueMin, or valueMax; otherwise the request returns HTTP 400. Must be NUMERIC when used with valueMin or valueMax. + + environment : typing.Optional[str] + Comma-separated list of environments to filter by. + + config_id : typing.Optional[str] + Comma-separated list of score config IDs to filter by. + + queue_id : typing.Optional[str] + Comma-separated list of annotation queue IDs to filter by. + + author_user_id : typing.Optional[str] + Comma-separated list of author user IDs to filter by. + + value : typing.Optional[str] + Comma-separated list of exact values to filter by. Requires a single dataType from NUMERIC, BOOLEAN, or CATEGORICAL; any other dataType, multiple dataTypes, or omitting dataType returns HTTP 400. For BOOLEAN, each value must be "true" or "false"; for NUMERIC, each value must be a finite number. Otherwise the request returns HTTP 400. + + value_min : typing.Optional[float] + Inclusive lower bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400. + + value_max : typing.Optional[float] + Inclusive upper bound on the numeric value. Requires dataType=NUMERIC as a single value; otherwise the request returns HTTP 400. + + trace_id : typing.Optional[str] + Comma-separated list of trace IDs to filter by. Mutually exclusive with sessionId, experimentId. May be combined with observationId to scope the observation lookup to a specific trace. + + session_id : typing.Optional[str] + Comma-separated list of session IDs to filter by. Mutually exclusive with traceId, observationId, experimentId. + + observation_id : typing.Optional[str] + Comma-separated list of observation IDs to filter by. Requires traceId to be specified, because observation IDs are scoped to a trace. Mutually exclusive with sessionId, experimentId. Returns HTTP 400 when used without traceId. + + experiment_id : typing.Optional[str] + Comma-separated list of dataset run IDs (experiment IDs) to filter by. Mutually exclusive with traceId, sessionId, observationId. + + from_timestamp : typing.Optional[dt.datetime] + Inclusive lower bound on the score timestamp. + + to_timestamp : typing.Optional[dt.datetime] + Exclusive upper bound on the score timestamp. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[GetScoresV3Response] + """ + _response = await self._client_wrapper.httpx_client.request( + "api/public/v3/scores", + method="GET", + params={ + "limit": limit, + "cursor": cursor, + "fields": fields, + "id": id, + "name": name, + "source": source, + "dataType": data_type, + "environment": environment, + "configId": config_id, + "queueId": queue_id, + "authorUserId": author_user_id, + "value": value, + "valueMin": value_min, + "valueMax": value_max, + "traceId": trace_id, + "sessionId": session_id, + "observationId": observation_id, + "experimentId": experiment_id, + "fromTimestamp": serialize_datetime(from_timestamp) + if from_timestamp is not None + else None, + "toTimestamp": serialize_datetime(to_timestamp) + if to_timestamp is not None + else None, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + GetScoresV3Response, + parse_obj_as( + type_=GetScoresV3Response, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 400: + raise Error( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 403: + raise AccessDeniedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 405: + raise MethodNotAllowedError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + typing.Any, + parse_obj_as( + type_=typing.Any, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError( + status_code=_response.status_code, + headers=dict(_response.headers), + body=_response.text, + ) + raise ApiError( + status_code=_response.status_code, + headers=dict(_response.headers), + body=_response_json, + ) diff --git a/langfuse/api/scores_v3/types/__init__.py b/langfuse/api/scores_v3/types/__init__.py new file mode 100644 index 000000000..14da0ca73 --- /dev/null +++ b/langfuse/api/scores_v3/types/__init__.py @@ -0,0 +1,114 @@ +# This file was auto-generated by Fern from our API Definition. + +# isort: skip_file + +import typing +from importlib import import_module + +if typing.TYPE_CHECKING: + from .base_score_v3 import BaseScoreV3 + from .boolean_score_v3 import BooleanScoreV3 + from .categorical_score_v3 import CategoricalScoreV3 + from .correction_score_v3 import CorrectionScoreV3 + from .get_scores_v3meta import GetScoresV3Meta + from .get_scores_v3response import GetScoresV3Response + from .numeric_score_v3 import NumericScoreV3 + from .score_subject_experiment_v3 import ScoreSubjectExperimentV3 + from .score_subject_observation_v3 import ScoreSubjectObservationV3 + from .score_subject_session_v3 import ScoreSubjectSessionV3 + from .score_subject_trace_v3 import ScoreSubjectTraceV3 + from .score_subject_v3 import ( + ScoreSubjectV3, + ScoreSubjectV3_Experiment, + ScoreSubjectV3_Observation, + ScoreSubjectV3_Session, + ScoreSubjectV3_Trace, + ) + from .score_v3 import ( + ScoreV3, + ScoreV3_Boolean, + ScoreV3_Categorical, + ScoreV3_Correction, + ScoreV3_Numeric, + ScoreV3_Text, + ) + from .text_score_v3 import TextScoreV3 +_dynamic_imports: typing.Dict[str, str] = { + "BaseScoreV3": ".base_score_v3", + "BooleanScoreV3": ".boolean_score_v3", + "CategoricalScoreV3": ".categorical_score_v3", + "CorrectionScoreV3": ".correction_score_v3", + "GetScoresV3Meta": ".get_scores_v3meta", + "GetScoresV3Response": ".get_scores_v3response", + "NumericScoreV3": ".numeric_score_v3", + "ScoreSubjectExperimentV3": ".score_subject_experiment_v3", + "ScoreSubjectObservationV3": ".score_subject_observation_v3", + "ScoreSubjectSessionV3": ".score_subject_session_v3", + "ScoreSubjectTraceV3": ".score_subject_trace_v3", + "ScoreSubjectV3": ".score_subject_v3", + "ScoreSubjectV3_Experiment": ".score_subject_v3", + "ScoreSubjectV3_Observation": ".score_subject_v3", + "ScoreSubjectV3_Session": ".score_subject_v3", + "ScoreSubjectV3_Trace": ".score_subject_v3", + "ScoreV3": ".score_v3", + "ScoreV3_Boolean": ".score_v3", + "ScoreV3_Categorical": ".score_v3", + "ScoreV3_Correction": ".score_v3", + "ScoreV3_Numeric": ".score_v3", + "ScoreV3_Text": ".score_v3", + "TextScoreV3": ".text_score_v3", +} + + +def __getattr__(attr_name: str) -> typing.Any: + module_name = _dynamic_imports.get(attr_name) + if module_name is None: + raise AttributeError( + f"No {attr_name} found in _dynamic_imports for module name -> {__name__}" + ) + try: + module = import_module(module_name, __package__) + if module_name == f".{attr_name}": + return module + else: + return getattr(module, attr_name) + except ImportError as e: + raise ImportError( + f"Failed to import {attr_name} from {module_name}: {e}" + ) from e + except AttributeError as e: + raise AttributeError( + f"Failed to get {attr_name} from {module_name}: {e}" + ) from e + + +def __dir__(): + lazy_attrs = list(_dynamic_imports.keys()) + return sorted(lazy_attrs) + + +__all__ = [ + "BaseScoreV3", + "BooleanScoreV3", + "CategoricalScoreV3", + "CorrectionScoreV3", + "GetScoresV3Meta", + "GetScoresV3Response", + "NumericScoreV3", + "ScoreSubjectExperimentV3", + "ScoreSubjectObservationV3", + "ScoreSubjectSessionV3", + "ScoreSubjectTraceV3", + "ScoreSubjectV3", + "ScoreSubjectV3_Experiment", + "ScoreSubjectV3_Observation", + "ScoreSubjectV3_Session", + "ScoreSubjectV3_Trace", + "ScoreV3", + "ScoreV3_Boolean", + "ScoreV3_Categorical", + "ScoreV3_Correction", + "ScoreV3_Numeric", + "ScoreV3_Text", + "TextScoreV3", +] diff --git a/langfuse/api/scores_v3/types/base_score_v3.py b/langfuse/api/scores_v3/types/base_score_v3.py new file mode 100644 index 000000000..3d5394f95 --- /dev/null +++ b/langfuse/api/scores_v3/types/base_score_v3.py @@ -0,0 +1,71 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic +import typing_extensions +from ...commons.types.score_source import ScoreSource +from ...core.pydantic_utilities import UniversalBaseModel +from ...core.serialization import FieldMetadata +from .score_subject_v3 import ScoreSubjectV3 + + +class BaseScoreV3(UniversalBaseModel): + id: str + project_id: typing_extensions.Annotated[str, FieldMetadata(alias="projectId")] + name: str + source: ScoreSource + timestamp: dt.datetime + environment: str = pydantic.Field() + """ + The environment from which this score originated. + """ + + created_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="createdAt") + ] + updated_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="updatedAt") + ] + comment: typing.Optional[str] = pydantic.Field(default=None) + """ + Optional comment attached to the score. Present when "details" is included in the fields parameter. + """ + + config_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="configId") + ] = pydantic.Field(default=None) + """ + The score config ID, if this score was created from a config. Present when "details" is included in the fields parameter. + """ + + metadata: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field( + default=None + ) + """ + Arbitrary metadata attached to the score. Present when "details" is included in the fields parameter. + """ + + author_user_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="authorUserId") + ] = pydantic.Field(default=None) + """ + The user who created this score, if available. Present when "annotation" is included in the fields parameter. + """ + + queue_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="queueId") + ] = pydantic.Field(default=None) + """ + The annotation queue this score belongs to, if any. Present when "annotation" is included in the fields parameter. + """ + + subject: typing.Optional[ScoreSubjectV3] = pydantic.Field(default=None) + """ + The entity this score is attached to (trace, observation, session, or experiment). Present when "subject" is included in the fields parameter. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/boolean_score_v3.py b/langfuse/api/scores_v3/types/boolean_score_v3.py new file mode 100644 index 000000000..5b94bc1d1 --- /dev/null +++ b/langfuse/api/scores_v3/types/boolean_score_v3.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from .base_score_v3 import BaseScoreV3 + + +class BooleanScoreV3(BaseScoreV3): + value: bool = pydantic.Field() + """ + The boolean value of the score. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/categorical_score_v3.py b/langfuse/api/scores_v3/types/categorical_score_v3.py new file mode 100644 index 000000000..975b1f64c --- /dev/null +++ b/langfuse/api/scores_v3/types/categorical_score_v3.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from .base_score_v3 import BaseScoreV3 + + +class CategoricalScoreV3(BaseScoreV3): + value: str = pydantic.Field() + """ + The string category value of the score. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/correction_score_v3.py b/langfuse/api/scores_v3/types/correction_score_v3.py new file mode 100644 index 000000000..1717a6e67 --- /dev/null +++ b/langfuse/api/scores_v3/types/correction_score_v3.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from .base_score_v3 import BaseScoreV3 + + +class CorrectionScoreV3(BaseScoreV3): + value: str = pydantic.Field() + """ + The correction content of the score. Empty string if not set. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/get_scores_v3meta.py b/langfuse/api/scores_v3/types/get_scores_v3meta.py new file mode 100644 index 000000000..7dfcfe0e1 --- /dev/null +++ b/langfuse/api/scores_v3/types/get_scores_v3meta.py @@ -0,0 +1,18 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ...core.pydantic_utilities import UniversalBaseModel + + +class GetScoresV3Meta(UniversalBaseModel): + limit: int + cursor: typing.Optional[str] = pydantic.Field(default=None) + """ + URL-safe base64 (base64url) cursor for the next page. Absent when there are no more results. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/get_scores_v3response.py b/langfuse/api/scores_v3/types/get_scores_v3response.py new file mode 100644 index 000000000..4d625b29a --- /dev/null +++ b/langfuse/api/scores_v3/types/get_scores_v3response.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ...core.pydantic_utilities import UniversalBaseModel +from .get_scores_v3meta import GetScoresV3Meta +from .score_v3 import ScoreV3 + + +class GetScoresV3Response(UniversalBaseModel): + data: typing.List[ScoreV3] + meta: GetScoresV3Meta + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/numeric_score_v3.py b/langfuse/api/scores_v3/types/numeric_score_v3.py new file mode 100644 index 000000000..10df001a4 --- /dev/null +++ b/langfuse/api/scores_v3/types/numeric_score_v3.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from .base_score_v3 import BaseScoreV3 + + +class NumericScoreV3(BaseScoreV3): + value: float = pydantic.Field() + """ + The numeric value of the score. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/score_subject_experiment_v3.py b/langfuse/api/scores_v3/types/score_subject_experiment_v3.py new file mode 100644 index 000000000..a71a49241 --- /dev/null +++ b/langfuse/api/scores_v3/types/score_subject_experiment_v3.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ...core.pydantic_utilities import UniversalBaseModel + + +class ScoreSubjectExperimentV3(UniversalBaseModel): + id: str = pydantic.Field() + """ + The dataset run ID (experiment ID). + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/score_subject_observation_v3.py b/langfuse/api/scores_v3/types/score_subject_observation_v3.py new file mode 100644 index 000000000..1bc2edf20 --- /dev/null +++ b/langfuse/api/scores_v3/types/score_subject_observation_v3.py @@ -0,0 +1,26 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +import typing_extensions +from ...core.pydantic_utilities import UniversalBaseModel +from ...core.serialization import FieldMetadata + + +class ScoreSubjectObservationV3(UniversalBaseModel): + id: str = pydantic.Field() + """ + The observation ID. + """ + + trace_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="traceId") + ] = pydantic.Field(default=None) + """ + The parent trace ID, if available. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/score_subject_session_v3.py b/langfuse/api/scores_v3/types/score_subject_session_v3.py new file mode 100644 index 000000000..cb9347583 --- /dev/null +++ b/langfuse/api/scores_v3/types/score_subject_session_v3.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ...core.pydantic_utilities import UniversalBaseModel + + +class ScoreSubjectSessionV3(UniversalBaseModel): + id: str = pydantic.Field() + """ + The session ID. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/score_subject_trace_v3.py b/langfuse/api/scores_v3/types/score_subject_trace_v3.py new file mode 100644 index 000000000..26aab7f07 --- /dev/null +++ b/langfuse/api/scores_v3/types/score_subject_trace_v3.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ...core.pydantic_utilities import UniversalBaseModel + + +class ScoreSubjectTraceV3(UniversalBaseModel): + id: str = pydantic.Field() + """ + The trace ID. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) diff --git a/langfuse/api/scores_v3/types/score_subject_v3.py b/langfuse/api/scores_v3/types/score_subject_v3.py new file mode 100644 index 000000000..7464fda55 --- /dev/null +++ b/langfuse/api/scores_v3/types/score_subject_v3.py @@ -0,0 +1,76 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations + +import typing + +import pydantic +import typing_extensions +from ...core.pydantic_utilities import UniversalBaseModel +from ...core.serialization import FieldMetadata + + +class ScoreSubjectV3_Trace(UniversalBaseModel): + """ + A reference to the entity this score is attached to. Discriminated by "kind" — one of trace, observation, session, or experiment. + """ + + kind: typing.Literal["trace"] = "trace" + id: str + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) + + +class ScoreSubjectV3_Observation(UniversalBaseModel): + """ + A reference to the entity this score is attached to. Discriminated by "kind" — one of trace, observation, session, or experiment. + """ + + kind: typing.Literal["observation"] = "observation" + id: str + trace_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="traceId") + ] = None + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) + + +class ScoreSubjectV3_Session(UniversalBaseModel): + """ + A reference to the entity this score is attached to. Discriminated by "kind" — one of trace, observation, session, or experiment. + """ + + kind: typing.Literal["session"] = "session" + id: str + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) + + +class ScoreSubjectV3_Experiment(UniversalBaseModel): + """ + A reference to the entity this score is attached to. Discriminated by "kind" — one of trace, observation, session, or experiment. + """ + + kind: typing.Literal["experiment"] = "experiment" + id: str + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) + + +ScoreSubjectV3 = typing_extensions.Annotated[ + typing.Union[ + ScoreSubjectV3_Trace, + ScoreSubjectV3_Observation, + ScoreSubjectV3_Session, + ScoreSubjectV3_Experiment, + ], + pydantic.Field(discriminator="kind"), +] diff --git a/langfuse/api/scores_v3/types/score_v3.py b/langfuse/api/scores_v3/types/score_v3.py new file mode 100644 index 000000000..9921d1bda --- /dev/null +++ b/langfuse/api/scores_v3/types/score_v3.py @@ -0,0 +1,200 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations + +import datetime as dt +import typing + +import pydantic +import typing_extensions +from ...commons.types.score_source import ScoreSource +from ...core.pydantic_utilities import UniversalBaseModel +from ...core.serialization import FieldMetadata +from .score_subject_v3 import ScoreSubjectV3 + + +class ScoreV3_Numeric(UniversalBaseModel): + data_type: typing_extensions.Annotated[ + typing.Literal["NUMERIC"], FieldMetadata(alias="dataType") + ] = "NUMERIC" + value: float + id: str + project_id: typing_extensions.Annotated[str, FieldMetadata(alias="projectId")] + name: str + source: ScoreSource + timestamp: dt.datetime + environment: str + created_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="createdAt") + ] + updated_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="updatedAt") + ] + comment: typing.Optional[str] = None + config_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="configId") + ] = None + metadata: typing.Optional[typing.Dict[str, typing.Any]] = None + author_user_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="authorUserId") + ] = None + queue_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="queueId") + ] = None + subject: typing.Optional[ScoreSubjectV3] = None + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) + + +class ScoreV3_Boolean(UniversalBaseModel): + data_type: typing_extensions.Annotated[ + typing.Literal["BOOLEAN"], FieldMetadata(alias="dataType") + ] = "BOOLEAN" + value: bool + id: str + project_id: typing_extensions.Annotated[str, FieldMetadata(alias="projectId")] + name: str + source: ScoreSource + timestamp: dt.datetime + environment: str + created_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="createdAt") + ] + updated_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="updatedAt") + ] + comment: typing.Optional[str] = None + config_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="configId") + ] = None + metadata: typing.Optional[typing.Dict[str, typing.Any]] = None + author_user_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="authorUserId") + ] = None + queue_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="queueId") + ] = None + subject: typing.Optional[ScoreSubjectV3] = None + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) + + +class ScoreV3_Categorical(UniversalBaseModel): + data_type: typing_extensions.Annotated[ + typing.Literal["CATEGORICAL"], FieldMetadata(alias="dataType") + ] = "CATEGORICAL" + value: str + id: str + project_id: typing_extensions.Annotated[str, FieldMetadata(alias="projectId")] + name: str + source: ScoreSource + timestamp: dt.datetime + environment: str + created_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="createdAt") + ] + updated_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="updatedAt") + ] + comment: typing.Optional[str] = None + config_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="configId") + ] = None + metadata: typing.Optional[typing.Dict[str, typing.Any]] = None + author_user_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="authorUserId") + ] = None + queue_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="queueId") + ] = None + subject: typing.Optional[ScoreSubjectV3] = None + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) + + +class ScoreV3_Text(UniversalBaseModel): + data_type: typing_extensions.Annotated[ + typing.Literal["TEXT"], FieldMetadata(alias="dataType") + ] = "TEXT" + value: str + id: str + project_id: typing_extensions.Annotated[str, FieldMetadata(alias="projectId")] + name: str + source: ScoreSource + timestamp: dt.datetime + environment: str + created_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="createdAt") + ] + updated_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="updatedAt") + ] + comment: typing.Optional[str] = None + config_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="configId") + ] = None + metadata: typing.Optional[typing.Dict[str, typing.Any]] = None + author_user_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="authorUserId") + ] = None + queue_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="queueId") + ] = None + subject: typing.Optional[ScoreSubjectV3] = None + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) + + +class ScoreV3_Correction(UniversalBaseModel): + data_type: typing_extensions.Annotated[ + typing.Literal["CORRECTION"], FieldMetadata(alias="dataType") + ] = "CORRECTION" + value: str + id: str + project_id: typing_extensions.Annotated[str, FieldMetadata(alias="projectId")] + name: str + source: ScoreSource + timestamp: dt.datetime + environment: str + created_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="createdAt") + ] + updated_at: typing_extensions.Annotated[ + dt.datetime, FieldMetadata(alias="updatedAt") + ] + comment: typing.Optional[str] = None + config_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="configId") + ] = None + metadata: typing.Optional[typing.Dict[str, typing.Any]] = None + author_user_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="authorUserId") + ] = None + queue_id: typing_extensions.Annotated[ + typing.Optional[str], FieldMetadata(alias="queueId") + ] = None + subject: typing.Optional[ScoreSubjectV3] = None + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + ) + + +ScoreV3 = typing_extensions.Annotated[ + typing.Union[ + ScoreV3_Numeric, + ScoreV3_Boolean, + ScoreV3_Categorical, + ScoreV3_Text, + ScoreV3_Correction, + ], + pydantic.Field(discriminator="data_type"), +] diff --git a/langfuse/api/scores_v3/types/text_score_v3.py b/langfuse/api/scores_v3/types/text_score_v3.py new file mode 100644 index 000000000..3d658972c --- /dev/null +++ b/langfuse/api/scores_v3/types/text_score_v3.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from .base_score_v3 import BaseScoreV3 + + +class TextScoreV3(BaseScoreV3): + value: str = pydantic.Field() + """ + The text content of the score. + """ + + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow", frozen=True + )