fix(batch-evaluation): pass trace ID for score creation if scope = observations#1504
Merged
fix(batch-evaluation): pass trace ID for score creation if scope = observations#1504
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclaimer: Experimental PR review
Greptile Overview
Greptile Summary
Fixed batch evaluation score creation for observations by passing the required
trace_idparameter. When creating scores for observations, the Langfuse API requires bothobservation_idandtrace_id. This PR correctly extracts thetrace_idfrom theObservationsViewitem and passes it to_create_score_for_scope.Key changes:
castimport at the top of the module_create_score_for_scopeto accept optionaltrace_idparameter (keyword-only)trace_idwhenscope == "observations"Confidence Score: 5/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant Caller participant BatchEvaluationRunner participant Evaluator participant LangfuseClient Caller->>BatchEvaluationRunner: run_batched_evaluation(scope="observations") BatchEvaluationRunner->>BatchEvaluationRunner: fetch observations loop For each observation BatchEvaluationRunner->>BatchEvaluationRunner: _process_batch_evaluation_item(item) BatchEvaluationRunner->>Evaluator: run evaluator on observation Evaluator-->>BatchEvaluationRunner: evaluation result Note over BatchEvaluationRunner: Extract trace_id from ObservationsView BatchEvaluationRunner->>BatchEvaluationRunner: cast(ObservationsView, item).trace_id BatchEvaluationRunner->>BatchEvaluationRunner: _create_score_for_scope(scope, item_id, trace_id) alt scope == "observations" BatchEvaluationRunner->>LangfuseClient: create_score(observation_id, trace_id, ...) else scope == "traces" BatchEvaluationRunner->>LangfuseClient: create_score(trace_id, ...) end LangfuseClient-->>BatchEvaluationRunner: score created end BatchEvaluationRunner-->>Caller: BatchEvaluationResult