From e39c408350280e3f26142998218d6c1b27b7d776 Mon Sep 17 00:00:00 2001 From: Kate Yeh Date: Mon, 29 Apr 2024 11:13:00 -0700 Subject: [PATCH] changed to decimal lib --- agentops/client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/agentops/client.py b/agentops/client.py index 55520487..37676f26 100644 --- a/agentops/client.py +++ b/agentops/client.py @@ -15,12 +15,14 @@ from typing import Optional, List import traceback from .log_config import logger, set_logging_level_info +from decimal import * import inspect import atexit import signal import sys import threading + from .meta_client import MetaClient from .config import Configuration, ConfigurationError from .llm_tracker import LlmTracker @@ -264,11 +266,13 @@ def end_session(self, self._session.video = video self._session.end_session(end_state, end_state_reason) - token_cost = self._worker.end_session(self._session) + getcontext().prec = 6 + token_cost = Decimal(self._worker.end_session(self._session)) if token_cost == 'unknown': print('🖇 AgentOps: Could not determine cost of run.') else: - print('🖇 AgentOps: This run cost ${}'.format('{:.2f}'.format(token_cost) if token_cost == 0 else '{:.6f}'.format(float(token_cost)))) + + print('🖇 AgentOps: This run cost ${}'.format('{:.2f}'.format(token_cost) if token_cost == 0 else '{:.6f}'.format(token_cost))) self._session = None self._worker = None