From 3cc436957be16912e3621405c9132bd2ecf2c0b6 Mon Sep 17 00:00:00 2001 From: langfuse-bot Date: Tue, 13 Oct 2026 20:00:02 +0000 Subject: [PATCH 1/2] feat(api): update API spec from langfuse/langfuse f0ea0c3 --- langfuse/api/__init__.py | 6 ---- langfuse/api/scores/__init__.py | 6 ---- langfuse/api/scores/client.py | 32 +++++++++++++------ langfuse/api/scores/raw_client.py | 4 +-- langfuse/api/scores/types/__init__.py | 6 ---- .../types/create_score_batch_request.py | 25 --------------- .../api/scores/types/create_score_response.py | 17 ---------- .../api/scores/types/create_scores_request.py | 21 ++++++++++-- .../scores/types/create_scores_response.py | 5 +-- 9 files changed, 44 insertions(+), 78 deletions(-) delete mode 100644 langfuse/api/scores/types/create_score_batch_request.py delete mode 100644 langfuse/api/scores/types/create_score_response.py diff --git a/langfuse/api/__init__.py b/langfuse/api/__init__.py index b058ced5a..0952ed7d5 100644 --- a/langfuse/api/__init__.py +++ b/langfuse/api/__init__.py @@ -398,11 +398,9 @@ CategoricalScoreV3, CorrectionScoreV3, CreateScoreBatchError, - CreateScoreBatchRequest, CreateScoreBatchResponse, CreateScoreBatchResults, CreateScoreRequest, - CreateScoreResponse, CreateScoreSource, CreateScoresRequest, CreateScoresResponse, @@ -502,12 +500,10 @@ "CreateObservationEvent": ".ingestion", "CreatePromptRequest": ".prompts", "CreateScoreBatchError": ".scores", - "CreateScoreBatchRequest": ".scores", "CreateScoreBatchResponse": ".scores", "CreateScoreBatchResults": ".scores", "CreateScoreConfigRequest": ".score_configs", "CreateScoreRequest": ".scores", - "CreateScoreResponse": ".scores", "CreateScoreSource": ".scores", "CreateScoreValue": ".commons", "CreateScoresRequest": ".scores", @@ -916,12 +912,10 @@ def __dir__(): "CreateObservationEvent", "CreatePromptRequest", "CreateScoreBatchError", - "CreateScoreBatchRequest", "CreateScoreBatchResponse", "CreateScoreBatchResults", "CreateScoreConfigRequest", "CreateScoreRequest", - "CreateScoreResponse", "CreateScoreSource", "CreateScoreValue", "CreateScoresRequest", diff --git a/langfuse/api/scores/__init__.py b/langfuse/api/scores/__init__.py index d0251574f..a92174549 100644 --- a/langfuse/api/scores/__init__.py +++ b/langfuse/api/scores/__init__.py @@ -12,11 +12,9 @@ CategoricalScoreV3, CorrectionScoreV3, CreateScoreBatchError, - CreateScoreBatchRequest, CreateScoreBatchResponse, CreateScoreBatchResults, CreateScoreRequest, - CreateScoreResponse, CreateScoreSource, CreateScoresRequest, CreateScoresResponse, @@ -46,11 +44,9 @@ "CategoricalScoreV3": ".types", "CorrectionScoreV3": ".types", "CreateScoreBatchError": ".types", - "CreateScoreBatchRequest": ".types", "CreateScoreBatchResponse": ".types", "CreateScoreBatchResults": ".types", "CreateScoreRequest": ".types", - "CreateScoreResponse": ".types", "CreateScoreSource": ".types", "CreateScoresRequest": ".types", "CreateScoresResponse": ".types", @@ -109,11 +105,9 @@ def __dir__(): "CategoricalScoreV3", "CorrectionScoreV3", "CreateScoreBatchError", - "CreateScoreBatchRequest", "CreateScoreBatchResponse", "CreateScoreBatchResults", "CreateScoreRequest", - "CreateScoreResponse", "CreateScoreSource", "CreateScoresRequest", "CreateScoresResponse", diff --git a/langfuse/api/scores/client.py b/langfuse/api/scores/client.py index feac3cbca..c5582cfc5 100644 --- a/langfuse/api/scores/client.py +++ b/langfuse/api/scores/client.py @@ -36,7 +36,7 @@ def create( request_options: typing.Optional[RequestOptions] = None, ) -> CreateScoresResponse: """ - Create scores asynchronously. Single score: 200 with ID. Batch: 202 if accepted, or 207 with accepted/rejected counts and error messages. Do not automatically retry a 207 batch. The generated reference shows only 200; batches return 202 or 207. + Create scores asynchronously from a list of scores. Returns 202 if all scores are accepted, or 207 with accepted/rejected counts and error messages. Do not automatically retry a 207 batch. The generated reference shows only 200; the endpoint returns 202 or 207. Parameters ---------- @@ -63,10 +63,16 @@ def create( base_url="https://yourhost.com/path/to/api", ) client.scores.create( - request=CreateScoreRequest( - name="name", - value=1.1, - ), + request=[ + CreateScoreRequest( + name="name", + value=1.1, + ), + CreateScoreRequest( + name="name", + value=1.1, + ), + ], ) """ _response = self._raw_client.create( @@ -287,7 +293,7 @@ async def create( request_options: typing.Optional[RequestOptions] = None, ) -> CreateScoresResponse: """ - Create scores asynchronously. Single score: 200 with ID. Batch: 202 if accepted, or 207 with accepted/rejected counts and error messages. Do not automatically retry a 207 batch. The generated reference shows only 200; batches return 202 or 207. + Create scores asynchronously from a list of scores. Returns 202 if all scores are accepted, or 207 with accepted/rejected counts and error messages. Do not automatically retry a 207 batch. The generated reference shows only 200; the endpoint returns 202 or 207. Parameters ---------- @@ -319,10 +325,16 @@ async def create( async def main() -> None: await client.scores.create( - request=CreateScoreRequest( - name="name", - value=1.1, - ), + request=[ + CreateScoreRequest( + name="name", + value=1.1, + ), + CreateScoreRequest( + name="name", + value=1.1, + ), + ], ) diff --git a/langfuse/api/scores/raw_client.py b/langfuse/api/scores/raw_client.py index d0cb9663c..fcc599f7f 100644 --- a/langfuse/api/scores/raw_client.py +++ b/langfuse/api/scores/raw_client.py @@ -36,7 +36,7 @@ def create( request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[CreateScoresResponse]: """ - Create scores asynchronously. Single score: 200 with ID. Batch: 202 if accepted, or 207 with accepted/rejected counts and error messages. Do not automatically retry a 207 batch. The generated reference shows only 200; batches return 202 or 207. + Create scores asynchronously from a list of scores. Returns 202 if all scores are accepted, or 207 with accepted/rejected counts and error messages. Do not automatically retry a 207 batch. The generated reference shows only 200; the endpoint returns 202 or 207. Parameters ---------- @@ -465,7 +465,7 @@ async def create( request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[CreateScoresResponse]: """ - Create scores asynchronously. Single score: 200 with ID. Batch: 202 if accepted, or 207 with accepted/rejected counts and error messages. Do not automatically retry a 207 batch. The generated reference shows only 200; batches return 202 or 207. + Create scores asynchronously from a list of scores. Returns 202 if all scores are accepted, or 207 with accepted/rejected counts and error messages. Do not automatically retry a 207 batch. The generated reference shows only 200; the endpoint returns 202 or 207. Parameters ---------- diff --git a/langfuse/api/scores/types/__init__.py b/langfuse/api/scores/types/__init__.py index ae28d182b..d2578c4b5 100644 --- a/langfuse/api/scores/types/__init__.py +++ b/langfuse/api/scores/types/__init__.py @@ -11,11 +11,9 @@ from .categorical_score_v3 import CategoricalScoreV3 from .correction_score_v3 import CorrectionScoreV3 from .create_score_batch_error import CreateScoreBatchError - from .create_score_batch_request import CreateScoreBatchRequest from .create_score_batch_response import CreateScoreBatchResponse from .create_score_batch_results import CreateScoreBatchResults from .create_score_request import CreateScoreRequest - from .create_score_response import CreateScoreResponse from .create_score_source import CreateScoreSource from .create_scores_request import CreateScoresRequest from .create_scores_response import CreateScoresResponse @@ -48,11 +46,9 @@ "CategoricalScoreV3": ".categorical_score_v3", "CorrectionScoreV3": ".correction_score_v3", "CreateScoreBatchError": ".create_score_batch_error", - "CreateScoreBatchRequest": ".create_score_batch_request", "CreateScoreBatchResponse": ".create_score_batch_response", "CreateScoreBatchResults": ".create_score_batch_results", "CreateScoreRequest": ".create_score_request", - "CreateScoreResponse": ".create_score_response", "CreateScoreSource": ".create_score_source", "CreateScoresRequest": ".create_scores_request", "CreateScoresResponse": ".create_scores_response", @@ -111,11 +107,9 @@ def __dir__(): "CategoricalScoreV3", "CorrectionScoreV3", "CreateScoreBatchError", - "CreateScoreBatchRequest", "CreateScoreBatchResponse", "CreateScoreBatchResults", "CreateScoreRequest", - "CreateScoreResponse", "CreateScoreSource", "CreateScoresRequest", "CreateScoresResponse", diff --git a/langfuse/api/scores/types/create_score_batch_request.py b/langfuse/api/scores/types/create_score_batch_request.py deleted file mode 100644 index 47ab94b9b..000000000 --- a/langfuse/api/scores/types/create_score_batch_request.py +++ /dev/null @@ -1,25 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -from .create_score_request import CreateScoreRequest - -""" -from langfuse.commons import ScoreDataType -from langfuse.scores import CreateScoreRequest - -[ - CreateScoreRequest( - name="accuracy", - value=0.9, - trace_id="cdef-1234-5678-90ab", - ), - CreateScoreRequest( - name="helpfulness", - value=1.0, - data_type=ScoreDataType.BOOLEAN, - trace_id="cdef-1234-5678-90ab", - ), -] -""" -CreateScoreBatchRequest = typing.List[CreateScoreRequest] diff --git a/langfuse/api/scores/types/create_score_response.py b/langfuse/api/scores/types/create_score_response.py deleted file mode 100644 index 1c20c0f3a..000000000 --- a/langfuse/api/scores/types/create_score_response.py +++ /dev/null @@ -1,17 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ...core.pydantic_utilities import UniversalBaseModel - - -class CreateScoreResponse(UniversalBaseModel): - id: str = pydantic.Field() - """ - The id of the created object in Langfuse - """ - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/scores/types/create_scores_request.py b/langfuse/api/scores/types/create_scores_request.py index 2acfce283..3c11bdfc9 100644 --- a/langfuse/api/scores/types/create_scores_request.py +++ b/langfuse/api/scores/types/create_scores_request.py @@ -2,7 +2,24 @@ import typing -from .create_score_batch_request import CreateScoreBatchRequest from .create_score_request import CreateScoreRequest -CreateScoresRequest = typing.Union[CreateScoreRequest, CreateScoreBatchRequest] +""" +from langfuse.commons import ScoreDataType +from langfuse.scores import CreateScoreRequest + +[ + CreateScoreRequest( + name="accuracy", + value=0.9, + trace_id="cdef-1234-5678-90ab", + ), + CreateScoreRequest( + name="helpfulness", + value=1.0, + data_type=ScoreDataType.BOOLEAN, + trace_id="cdef-1234-5678-90ab", + ), +] +""" +CreateScoresRequest = typing.List[CreateScoreRequest] diff --git a/langfuse/api/scores/types/create_scores_response.py b/langfuse/api/scores/types/create_scores_response.py index c3f4f7f10..7570cf33a 100644 --- a/langfuse/api/scores/types/create_scores_response.py +++ b/langfuse/api/scores/types/create_scores_response.py @@ -4,8 +4,5 @@ from .create_score_batch_response import CreateScoreBatchResponse from .create_score_batch_results import CreateScoreBatchResults -from .create_score_response import CreateScoreResponse -CreateScoresResponse = typing.Union[ - CreateScoreBatchResults, CreateScoreResponse, CreateScoreBatchResponse -] +CreateScoresResponse = typing.Union[CreateScoreBatchResults, CreateScoreBatchResponse] From f1df4a3ec8b14356b9fb1d2938d7c4a2c1a5cc50 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 13 Oct 2026 20:03:06 +0000 Subject: [PATCH 2/2] test: drop the single-score case from the scores create response test Co-authored-by: hassieb.pakzad --- tests/unit/test_scores_batch_response.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/unit/test_scores_batch_response.py b/tests/unit/test_scores_batch_response.py index c52eab692..ffc084620 100644 --- a/tests/unit/test_scores_batch_response.py +++ b/tests/unit/test_scores_batch_response.py @@ -19,16 +19,13 @@ CreateScoreBatchResults, ) from langfuse.api.scores.types.create_score_request import CreateScoreRequest -from langfuse.api.scores.types.create_score_response import CreateScoreResponse -SINGLE_REQUEST = CreateScoreRequest(name="accuracy", value=0.9, trace_id="trace-1") BATCH_REQUEST = [ CreateScoreRequest(name="accuracy", value=0.9, trace_id="trace-1"), CreateScoreRequest(name="tone", value="friendly", trace_id="trace-1"), ] CASES = [ - pytest.param(SINGLE_REQUEST, 200, {"id": "score-1"}, id="single-200"), pytest.param(BATCH_REQUEST, 202, {"message": "Accepted"}, id="batch-202"), pytest.param( BATCH_REQUEST, @@ -52,10 +49,7 @@ def handle(request: httpx.Request) -> httpx.Response: def _assert_parsed(response: Any, status: int, body: dict) -> None: - if status == 200: - assert isinstance(response, CreateScoreResponse) - assert response.id == body["id"] - elif status == 202: + if status == 202: assert isinstance(response, CreateScoreBatchResponse) assert response.message == "Accepted" else: