Skip to content

Commit 29b5f56

Browse files
gustavocidornelaswhoseoyster
authored andcommitted
fix(tracer): pull ground truth from root step only when it is defined
1 parent d91808a commit 29b5f56

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/openlayer/lib/tracing/tracer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ def create_step(
102102
ConfigLlmData(
103103
output_column_name="output",
104104
input_variable_names=input_variable_names,
105-
ground_truth_column_name="groundTruth",
106105
latency_column_name="latency",
107106
cost_column_name="cost",
108107
timestamp_column_name="inferenceTimestamp",
109108
inference_id_column_name="inferenceId",
110109
num_of_token_column_name="tokens",
111110
)
112111
)
113-
112+
if "groundTruth" in trace_data:
113+
config.update({"ground_truth_column_name": "groundTruth"})
114114
if "context" in trace_data:
115115
config.update({"context_column_name": "context"})
116116

@@ -386,13 +386,14 @@ def post_process_trace(
386386
"inferenceTimestamp": root_step.start_time,
387387
"inferenceId": str(root_step.id),
388388
"output": root_step.output,
389-
"groundTruth": root_step.ground_truth,
390389
"latency": root_step.latency,
391390
"cost": processed_steps[0].get("cost", 0),
392391
"tokens": processed_steps[0].get("tokens", 0),
393392
"steps": processed_steps,
394393
**root_step.metadata,
395394
}
395+
if root_step.ground_truth:
396+
trace_data["groundTruth"] = root_step.ground_truth
396397
if input_variables:
397398
trace_data.update(input_variables)
398399

0 commit comments

Comments
 (0)