From d39b49113e159853acaeefc67dbd98601e13c1b1 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vega Date: Mon, 25 Nov 2024 22:53:35 +0100 Subject: [PATCH 1/2] set default values --- .../agenta_backend/apis/fastapi/observability/utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/agenta-backend/agenta_backend/apis/fastapi/observability/utils.py b/agenta-backend/agenta_backend/apis/fastapi/observability/utils.py index 6a8a6ec462..71c6eac314 100644 --- a/agenta-backend/agenta_backend/apis/fastapi/observability/utils.py +++ b/agenta-backend/agenta_backend/apis/fastapi/observability/utils.py @@ -909,11 +909,11 @@ def parse_legacy_analytics( for bucket_dto in bucket_dtos: data_point = LegacyDataPoint( timestamp=bucket_dto.timestamp, - success_count=bucket_dto.total.count - bucket_dto.error.count, - failure_count=bucket_dto.error.count, - cost=bucket_dto.total.cost, - latency=bucket_dto.total.duration, - total_tokens=bucket_dto.total.tokens, + success_count=(bucket_dto.total.count - bucket_dto.error.count) or 0, + failure_count=bucket_dto.error.count or 0, + cost=bucket_dto.total.cost or 0.0, + latency=bucket_dto.total.duration or 0.0, + total_tokens=bucket_dto.total.tokens or 0, ) data_points.append(data_point) From ac62dfcab4584f58ef01519b224b323449f1c88a Mon Sep 17 00:00:00 2001 From: jp-agenta Date: Tue, 26 Nov 2024 09:25:44 +0100 Subject: [PATCH 2/2] Update utils.py --- .../agenta_backend/apis/fastapi/observability/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agenta-backend/agenta_backend/apis/fastapi/observability/utils.py b/agenta-backend/agenta_backend/apis/fastapi/observability/utils.py index 71c6eac314..188f93cfa8 100644 --- a/agenta-backend/agenta_backend/apis/fastapi/observability/utils.py +++ b/agenta-backend/agenta_backend/apis/fastapi/observability/utils.py @@ -909,7 +909,7 @@ def parse_legacy_analytics( for bucket_dto in bucket_dtos: data_point = LegacyDataPoint( timestamp=bucket_dto.timestamp, - success_count=(bucket_dto.total.count - bucket_dto.error.count) or 0, + success_count=(bucket_dto.total.count or 0) - (bucket_dto.error.count or 0), failure_count=bucket_dto.error.count or 0, cost=bucket_dto.total.cost or 0.0, latency=bucket_dto.total.duration or 0.0,