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