From 6bef885a19cb5fe0330ee87c05b5942ffcba203c Mon Sep 17 00:00:00 2001 From: Oras Al-Kubaisi Date: Wed, 8 Jan 2025 15:06:46 +0000 Subject: [PATCH] checking if the value of the metric is an int to avoid the warning Failed to calculate metrics due to exception: unsupported operand type(s) for +: 'int' and 'dict' --- src/promptflow-tracing/promptflow/tracing/_openai_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/promptflow-tracing/promptflow/tracing/_openai_utils.py b/src/promptflow-tracing/promptflow/tracing/_openai_utils.py index 3ef876faf17..e4defb44293 100644 --- a/src/promptflow-tracing/promptflow/tracing/_openai_utils.py +++ b/src/promptflow-tracing/promptflow/tracing/_openai_utils.py @@ -197,7 +197,8 @@ def _get_completion_tokens_for_completion_api(self, output, enc): def merge_metrics_dict(self, metrics: dict, metrics_to_merge: dict): for k, v in metrics_to_merge.items(): - metrics[k] = metrics.get(k, 0) + v + if isinstance(v, int): + metrics[k] = metrics.get(k, 0) + v def _log_warning(self, msg): if self._logger: