Skip to content

Commit

Permalink
Fix metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkbrnd committed Feb 12, 2025
1 parent 4ee5f52 commit bc2004c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libs/agno/agno/models/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class MessageMetrics:
def _to_dict(self) -> Dict[str, Any]:
metrics_dict = asdict(self)
metrics_dict.pop("timer")
metrics_dict = {k: v for k, v in metrics_dict.items() if v is not None}
metrics_dict = {k: v for k, v in metrics_dict.items()
if v is not None and
(not isinstance(v, (int, float)) or v != 0)}
return metrics_dict

def start_timer(self):
Expand Down Expand Up @@ -215,9 +217,11 @@ def to_dict(self) -> Dict[str, Any]:
message_dict["references"] = asdict(self.references)
if self.metrics:
message_dict["metrics"] = self.metrics._to_dict()
if not message_dict["metrics"]:
message_dict.pop("metrics")

message_dict["created_at"] = self.created_at

print("HERE", message_dict)
return message_dict

def to_fc_result(self) -> Dict[str, Any]:
Expand Down

0 comments on commit bc2004c

Please sign in to comment.