Skip to content

Commit

Permalink
checking if the value of the metric is an int to avoid the warning Fa…
Browse files Browse the repository at this point in the history
…iled to calculate metrics due to exception: unsupported operand type(s) for +: 'int' and 'dict'
  • Loading branch information
orasik committed Jan 8, 2025
1 parent 3c3c72f commit 6bef885
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/promptflow-tracing/promptflow/tracing/_openai_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6bef885

Please sign in to comment.