Skip to content

Commit 0e488ab

Browse files
committed
fix alert types
1 parent 0185784 commit 0e488ab

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/judgeval/common/tracer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import json
1919
from contextlib import contextmanager, asynccontextmanager, AbstractAsyncContextManager, AbstractContextManager # Import context manager bases
2020
from dataclasses import dataclass, field
21-
from datetime import datetime
21+
from datetime import datetime, timezone
2222
from http import HTTPStatus
2323
from typing import (
2424
Any,
@@ -594,7 +594,7 @@ def save(self, overwrite: bool = False) -> Tuple[str, dict]:
594594
"trace_id": self.trace_id,
595595
"name": self.name,
596596
"project_name": self.project_name,
597-
"created_at": datetime.utcfromtimestamp(self.start_time).isoformat(),
597+
"created_at": datetime.fromtimestamp(self.start_time, timezone.utc).isoformat(),
598598
"duration": total_duration,
599599
"trace_spans": [span.model_dump() for span in self.trace_spans],
600600
"evaluation_runs": [run.model_dump() for run in self.evaluation_runs],

src/judgeval/rules.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ def model_dump(self, **kwargs):
142142
# Create standardized metric representation needed by server API
143143
metric_data = {
144144
"score_type": "",
145-
"threshold": 0.0
145+
"threshold": 0.0,
146+
"name": ""
146147
}
147148

148149
# First try to use object's own serialization methods
@@ -180,6 +181,16 @@ def model_dump(self, **kwargs):
180181
# Use condition threshold if metric doesn't have one
181182
metric_data['threshold'] = self.conditions[i].threshold
182183

184+
# Make sure name is set
185+
if not metric_data.get('name'):
186+
if hasattr(metric_obj, '__name__'):
187+
metric_data['name'] = metric_obj.__name__
188+
elif hasattr(metric_obj, 'name'):
189+
metric_data['name'] = metric_obj.name
190+
else:
191+
# Fallback to score_type if available
192+
metric_data['name'] = metric_data.get('score_type', str(metric_obj))
193+
183194
# Update the condition with our properly serialized metric
184195
condition["metric"] = metric_data
185196

0 commit comments

Comments
 (0)