-
Notifications
You must be signed in to change notification settings - Fork 5
Let users configure other parameters when creating scores #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Let users configure other parameters when creating scores #48
Conversation
Greptile OverviewGreptile SummaryThis PR extends the score creation API to support three additional parameters: explicit score ID, session ID, and environment. These additions align with the Langfuse API capabilities and enable more granular filtering of score data. Key changes:
Issue found:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| lib/langfuse/client.rb | Added id, session_id, and environment parameters with documentation, but lacks validation for mutually exclusive parameters |
| lib/langfuse/score_client.rb | Implemented core logic for new parameters including id, session_id, and environment in event building, but missing validation for parameter constraints |
Sequence Diagram
sequenceDiagram
participant User
participant Langfuse Module
participant Client
participant ScoreClient
participant Queue
participant API
User->>Langfuse Module: create_score(name, value, id, session_id, environment, ...)
Langfuse Module->>Client: create_score(name, value, id, session_id, environment, ...)
Client->>ScoreClient: create(name, value, id, session_id, environment, ...)
ScoreClient->>ScoreClient: validate_name(name)
ScoreClient->>ScoreClient: normalize_value(value, data_type)
ScoreClient->>ScoreClient: build_score_event(...)
Note over ScoreClient: Generates UUID if id not provided
Note over ScoreClient: Conditionally includes sessionId, environment
ScoreClient->>Queue: << event
alt Batch size reached
ScoreClient->>API: send_batch(events)
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 1 comment
| def create(name:, value:, id: nil, trace_id: nil, session_id: nil, observation_id: nil, comment: nil, | ||
| metadata: nil, environment: nil, data_type: :numeric, dataset_run_id: nil, config_id: nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing validation for mutually exclusive parameters. The documentation in lib/langfuse/client.rb:286 states that only one of trace_id, session_id, or dataset_run_id should be provided, but there's no code enforcing this constraint.
| def create(name:, value:, id: nil, trace_id: nil, session_id: nil, observation_id: nil, comment: nil, | |
| metadata: nil, environment: nil, data_type: :numeric, dataset_run_id: nil, config_id: nil) | |
| def create(name:, value:, id: nil, trace_id: nil, session_id: nil, observation_id: nil, comment: nil, | |
| metadata: nil, environment: nil, data_type: :numeric, dataset_run_id: nil, config_id: nil) | |
| validate_name(name) | |
| validate_score_identifiers(trace_id: trace_id, session_id: session_id, observation_id: observation_id, dataset_run_id: dataset_run_id) |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
TL;DRThis change lets users set an explicit score ID, and configure the session ID and environment when creating scores.
WhyThe Langfuse API supports setting a score ID, session ID, and environment when creating a score. These properties help to filter score data in more granular systems.
Checklist