Skip to content

Commit

Permalink
changed to decimal lib
Browse files Browse the repository at this point in the history
  • Loading branch information
stateofkate committed Apr 29, 2024
1 parent a8e3717 commit e39c408
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
from typing import Optional, List
import traceback
from .log_config import logger, set_logging_level_info
from decimal import *

This comment has been minimized.

Copy link
@areibman

areibman Apr 30, 2024

Contributor

from import * is not good practice in general because of potential overrides. Better to from decimal import Decimal

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
Expand Down Expand Up @@ -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

This comment has been minimized.

Copy link
@areibman

areibman Apr 30, 2024

Contributor

What's this for?

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

Expand Down

0 comments on commit e39c408

Please sign in to comment.