Skip to content

Conversation

@langfuse-bot
Copy link
Collaborator

@langfuse-bot langfuse-bot commented Jan 1, 2026

Important

This PR updates the API spec by adding Organization and ScoreConfigDataType classes, enhancing existing classes, and improving API client functionality and documentation.

  • New Classes:
    • Add Organization class in organization.py for project association.
    • Add ScoreConfigDataType class in score_config_data_type.py for score configuration.
  • Class Updates:
    • Update ScoreDataType in score_data_type.py to include CORRECTION type.
    • Update ScoreBody in score_body.py to include a description for name field.
  • API Client Enhancements:
    • Add fields parameter to get() in score_v_2/client.py for field selection.
    • Add fields parameter to get_many() in observations/client.py for field selection.
  • Documentation:
    • Add recommendations to use v2 endpoints in metrics/client.py and observations/client.py for better performance.
  • Imports and Exports:
    • Update imports in __init__.py files to include new classes.
    • Update __all__ in __init__.py files to include new classes.

This description was created by Ellipsis for 518f2d1. You can customize this summary. It will automatically update as commits are pushed.

Disclaimer: Experimental PR review

Greptile Summary

Auto-generated API client update from upstream Langfuse API specification. Introduces type separation between score configurations and actual scores, adds organization context to projects, and enhances API v2 endpoints with field selection capabilities.

Key changes:

  • Introduced ScoreConfigDataType enum (NUMERIC, BOOLEAN, CATEGORICAL) separate from ScoreDataType (which includes CORRECTION) - this correctly reflects that score configs don't support CORRECTION type
  • Added Organization model and made it a required field on Project - breaking change for API consumers expecting previous Project schema
  • Added fields parameter to Score V2 endpoint for selective field retrieval
  • Updated documentation to recommend v2 endpoints for observations and metrics
  • All changes are auto-generated from API spec, ensuring client-server alignment

Confidence Score: 4/5

  • Safe to merge with awareness that Project model has breaking changes
  • Code is auto-generated from API spec with consistent patterns. The introduction of ScoreConfigDataType is semantically correct. However, adding the required organization field to Project is a breaking change that will affect consumers. Score reduced from 5 to 4 due to this backward compatibility concern, though the change properly reflects the upstream API.
  • Pay attention to langfuse/api/resources/projects/types/project.py - the required organization field is a breaking change

Important Files Changed

Filename Overview
langfuse/api/resources/commons/types/score_config_data_type.py Added new enum for score config data types (NUMERIC, BOOLEAN, CATEGORICAL) with visitor pattern
langfuse/api/resources/commons/types/score_config.py Updated to use ScoreConfigDataType instead of ScoreDataType for data_type field
langfuse/api/resources/projects/types/organization.py Added new Organization model with id and name fields
langfuse/api/resources/projects/types/project.py Added required organization field to Project model - breaking change for API consumers
langfuse/api/resources/score_v_2/client.py Added optional fields parameter for field selection in scores endpoint

Sequence Diagram

sequenceDiagram
    participant API as Langfuse API
    participant Client as Python SDK
    participant App as Application Code
    
    Note over API,App: Score Config Creation Flow
    App->>Client: Create score config with ScoreConfigDataType
    Client->>Client: Use ScoreConfigDataType enum (NUMERIC, BOOLEAN, CATEGORICAL)
    Client->>API: POST /api/public/score-configs
    API-->>Client: Return ScoreConfig with ScoreConfigDataType
    Client-->>App: ScoreConfig object
    
    Note over API,App: Score Creation Flow
    App->>Client: Create score with optional ScoreDataType
    Client->>Client: Use ScoreDataType enum (includes CORRECTION)
    Client->>API: POST score with value
    API-->>Client: Return Score
    Client-->>App: Score object
    
    Note over API,App: Project Retrieval Flow
    App->>Client: Get project details
    Client->>API: GET /api/public/projects
    API-->>Client: Return Project with Organization
    Client->>Client: Deserialize Project with nested Organization
    Client-->>App: Project object with organization field
    
    Note over API,App: Score V2 Query with Field Selection
    App->>Client: Query scores with field filter
    Client->>API: GET /api/public/v2/scores?fields=score
    API-->>Client: Return filtered score data
    Client-->>App: GetScoresResponse
Loading

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.

2 participants