Skip to content

feat(api): update API spec from langfuse/langfuse 1999706#1615

Merged
wochinge merged 9 commits intomainfrom
api-spec-bot-1999706
Apr 9, 2026
Merged

feat(api): update API spec from langfuse/langfuse 1999706#1615
wochinge merged 9 commits intomainfrom
api-spec-bot-1999706

Conversation

@langfuse-bot
Copy link
Copy Markdown
Collaborator

@langfuse-bot langfuse-bot commented Apr 8, 2026

Disclaimer: Experimental PR review

Greptile Summary

This PR is an auto-generated API spec update (via Fern from langfuse/langfuse 1999706) that adds two new capabilities to the Python SDK:

  1. TEXT score data type — introduces Score_Text, ScoreV1_Text, TextScore, TextScoreV1, GetScoresResponseData_Text, and GetScoresResponseDataText across the type hierarchy, and adds TEXT to the ScoreDataType and ScoreConfigDataType enums (with full visit() coverage).
  2. Selective field projection for GET /trace/{traceId} — adds an optional fields query parameter to both TraceClient.get() and AsyncTraceClient.get(), allowing callers to request only specific field groups (core, io, scores, observations, metrics).

All changes are consistently applied across the flat discriminated-union classes, the inheritance-based classes, and both sync/async client variants. The updated GetScoresResponseData union now correctly discriminates on all five data types.

Confidence Score: 5/5

Safe to merge — auto-generated, additive API update with no breaking changes.

All changes are auto-generated by Fern from an updated OpenAPI spec. The TEXT score type is added consistently across every layer of the type hierarchy (enums, flat discriminated-union classes, inheritance-based classes, v1 variants, response data types, and public exports). The fields query parameter addition to the trace endpoint is correctly threaded through both sync and async clients. No existing types were modified in a breaking way, no logic errors were found, and there are no security concerns.

No files require special attention.

Vulnerabilities

No security concerns identified. The changes are auto-generated API type definitions and a query-parameter pass-through; no auth logic, secret handling, or user-controlled input paths are modified.

Important Files Changed

Filename Overview
langfuse/api/commons/types/score.py Adds Score_Text variant and extends Score discriminated union — consistent with other score variants, correct data_type literal and fields.
langfuse/api/commons/types/score_v1.py Adds ScoreV1_Text variant and extends ScoreV1 union — mirrors the score.py pattern correctly; no CORRECTION variant expected in V1.
langfuse/api/commons/types/text_score.py New TextScore class inheriting from BaseScore with a string_value field — correctly models the text score base type.
langfuse/api/commons/types/text_score_v1.py New TextScoreV1 class inheriting from BaseScoreV1 — same pattern as TextScore, clean addition.
langfuse/api/commons/types/score_data_type.py Adds TEXT to ScoreDataType enum and includes it in visit() — complete and consistent.
langfuse/api/commons/types/score_config_data_type.py Adds TEXT to ScoreConfigDataType and updates visit()CORRECTION intentionally absent from config type (not configurable).
langfuse/api/scores/types/get_scores_response_data.py Adds flat GetScoresResponseData_Text variant and extends the discriminated union — correctly follows the existing flat pattern used by all other score variants.
langfuse/api/scores/types/get_scores_response_data_text.py New GetScoresResponseDataText using inheritance from TextScore — follows the same inheritance pattern as other score response data classes.
langfuse/api/trace/client.py Adds optional fields query parameter to both sync and async get() methods — correctly threaded through to raw client, with proper docstring.
langfuse/api/trace/raw_client.py Adds fields to raw GET params dict for trace endpoint — correctly passes the optional field to the HTTP request.
langfuse/api/init.py Exports all new types in TYPE_CHECKING block, dynamic imports dict, and __all__ — complete and consistent.
langfuse/api/ingestion/types/score_body.py Docstring updated to mention text score value constraints — no structural changes, clean update.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class BaseScore {
        +data_type: str
        +string_value: str
        +id: str
    }
    class BaseScoreV1 {
        +data_type: str
        +id: str
        +trace_id: str
    }
    class TextScore {
        +string_value: str
        +data_type: Literal["TEXT"]
    }
    class TextScoreV1 {
        +string_value: str
        +data_type: Literal["TEXT"]
    }
    class GetScoresResponseDataText {
        +trace: Optional[GetScoresResponseTraceData]
    }
    class Score_Text {
        +data_type: Literal["TEXT"]
        +string_value: str
        +environment: str
    }
    class ScoreV1_Text {
        +data_type: Literal["TEXT"]
        +string_value: str
        +trace_id: str
    }
    class GetScoresResponseData_Text {
        +data_type: Literal["TEXT"]
        +string_value: str
        +trace: Optional
    }
    class Score {
        <<Union>>
        Score_Numeric | Score_Categorical | Score_Boolean | Score_Correction | Score_Text
    }
    class ScoreV1 {
        <<Union>>
        ScoreV1_Numeric | ScoreV1_Categorical | ScoreV1_Boolean | ScoreV1_Text
    }
    class GetScoresResponseData {
        <<Union>>
        _Numeric | _Categorical | _Boolean | _Correction | _Text
    }
    BaseScore <|-- TextScore
    BaseScoreV1 <|-- TextScoreV1
    TextScore <|-- GetScoresResponseDataText
    Score_Text --|> Score
    ScoreV1_Text --|> ScoreV1
    GetScoresResponseData_Text --|> GetScoresResponseData
Loading

Reviews (1): Last reviewed commit: "feat(api): update API spec from langfuse..." | Re-trigger Greptile

@langfuse-bot langfuse-bot requested a review from sumerman April 8, 2026 14:10
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

@claude review

@wochinge
Copy link
Copy Markdown
Contributor

wochinge commented Apr 8, 2026

@sumerman Let me handle it - I have some pending changes anyway

wochinge and others added 5 commits April 8, 2026 16:22
Extend string-value overloads in create_score, score_current_span,
score_current_trace, score, and score_trace to accept TEXT alongside
CATEGORICAL. Update all related docstrings. Add ExperimentScoreType
to exclude TEXT from experiments/evals. Add integration test for TEXT
scores.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The spec update is now automated via PR from the langfuse repo.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update cast(Literal["CATEGORICAL"], ...) to include "TEXT" in
score/score_trace/score_current_span/score_current_trace impl bodies.
Add ExperimentScoreType to __all__ in types.py.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — my prior review incorrectly flagged gaps that were already fixed in this PR; both langfuse/types.py and the @overload signatures in client.py include TEXT, and ExperimentScoreType correctly excludes it.

Extended reasoning...

Overview

This PR adds the TEXT score data type across the full type hierarchy (auto-generated API layer, manually-maintained public SDK layer, v1 variants, response data types, public exports) and adds an optional fields query parameter to the GET /trace/{traceId} endpoint. 28 files are modified: auto-generated Fern types, two manually-maintained SDK files (langfuse/types.py and langfuse/_client/client.py), langfuse/experiment.py, and tests.

Security risks

None. Changes are type definitions, docstring updates, and a query-parameter pass-through with no auth, crypto, or permission logic.

Level of scrutiny

Low. This is an additive, auto-generated API spec update following established patterns. The only manual additions are: updating the ScoreDataType Literal in langfuse/types.py to include TEXT, expanding the @overload signatures in client.py and span.py, introducing ExperimentScoreType (TEXT excluded for experiments), and updating experiment.py to use that new type. All are correct and consistent.

Other factors

My previous review incorrectly flagged langfuse/types.py and the client.py overloads as missing TEXT — they were already fixed in the same PR commit. A new integration test (test_create_text_score) validates the end-to-end flow with retry logic. No breaking changes; no CODEOWNER-owned paths are touched.

Caching node_modules directly caused postinstall hooks (e.g. prisma
generate) to be skipped, leading to stale generated artifacts that
didn't match the current langfuse-server schema. Cache the pnpm store
instead so installs are still fast but hooks run properly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — the previously flagged type gaps have been resolved.

Extended reasoning...

Overview

This PR adds a TEXT score data type across the full SDK type hierarchy (auto-generated API layer, manually-maintained , high-level and overloads) and an optional query parameter to the trace GET endpoint. CI caching is improved (pnpm store vs node_modules), and a new integration test is added.

Security risks

None. All changes are additive type definitions and a query-parameter pass-through. No auth, crypto, or permission logic is touched.

Level of scrutiny

Low. The auto-generated layer is Fern-managed boilerplate; the manually-maintained changes are small and targeted. The previously identified gaps (stale literal, missing in overloads) were the substantive risk, and they have been corrected in this revision.

Other factors

My earlier inline comment (stale and missing overload variants) has been marked resolved, and the diff confirms both fixes are present. The new correctly excludes TEXT for eval/experiment contexts. No outstanding reviewer comments remain.

@wochinge wochinge requested a review from hassiebp April 8, 2026 19:39
@wochinge wochinge enabled auto-merge (squash) April 9, 2026 13:14
@wochinge wochinge removed the request for review from sumerman April 9, 2026 13:14
@blacksmith-sh

This comment has been minimized.

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — the issues I raised in my previous review have been fully addressed.

Extended reasoning...

Overview

The PR adds a TEXT score data type throughout the API type hierarchy (enums, discriminated-union classes, inheritance-based classes, v1 variants, response data types, exports) and a selective query parameter for . Changes span auto-generated API layer files, manually-maintained public SDK types, tests, CI config, and .

My Previous Feedback

My prior review flagged that still defined (missing TEXT) and the signatures in only accepted for string-valued scores. Both issues are now fixed in the updated diff: includes TEXT, the overloads accept , and a separate was introduced to correctly exclude TEXT from evals/experiments. All inline comments were marked resolved.

Security Risks

None. These are additive type definitions and a pass-through query parameter with no auth logic, secret handling, or user-controlled input processing.

Level of Scrutiny

Low-to-medium. The bulk of the change is auto-generated Fern output, which is mechanical. The manually-maintained fixes to , , and are small and correct. A new integration test covers the TEXT score path.

Other Factors

CI fix for the cache key (pnpm-lock.yaml vs package-lock.json) is correct. Adding as an explicit dev dependency is appropriate. No CODEOWNERs file exists to check.

@wochinge wochinge merged commit b18a59e into main Apr 9, 2026
41 of 61 checks passed
@wochinge wochinge deleted the api-spec-bot-1999706 branch April 9, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants