feat(api): update API spec from langfuse/langfuse 1999706#1615
feat(api): update API spec from langfuse/langfuse 1999706#1615
Conversation
|
@claude review |
|
@sumerman Let me handle it - I have some pending changes anyway |
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>
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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.
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:Score_Text,ScoreV1_Text,TextScore,TextScoreV1,GetScoresResponseData_Text, andGetScoresResponseDataTextacross the type hierarchy, and addsTEXTto theScoreDataTypeandScoreConfigDataTypeenums (with fullvisit()coverage).GET /trace/{traceId}— adds an optionalfieldsquery parameter to bothTraceClient.get()andAsyncTraceClient.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
GetScoresResponseDataunion 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
fieldsquery 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
Score_Textvariant and extendsScorediscriminated union — consistent with other score variants, correctdata_typeliteral and fields.ScoreV1_Textvariant and extendsScoreV1union — mirrors thescore.pypattern correctly; noCORRECTIONvariant expected in V1.TextScoreclass inheriting fromBaseScorewith astring_valuefield — correctly models the text score base type.TextScoreV1class inheriting fromBaseScoreV1— same pattern asTextScore, clean addition.TEXTtoScoreDataTypeenum and includes it invisit()— complete and consistent.TEXTtoScoreConfigDataTypeand updatesvisit()—CORRECTIONintentionally absent from config type (not configurable).GetScoresResponseData_Textvariant and extends the discriminated union — correctly follows the existing flat pattern used by all other score variants.GetScoresResponseDataTextusing inheritance fromTextScore— follows the same inheritance pattern as other score response data classes.fieldsquery parameter to both sync and asyncget()methods — correctly threaded through to raw client, with proper docstring.fieldsto raw GET params dict for trace endpoint — correctly passes the optional field to the HTTP request.__all__— complete and consistent.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 --|> GetScoresResponseDataReviews (1): Last reviewed commit: "feat(api): update API spec from langfuse..." | Re-trigger Greptile