Skip to content

Commit

Permalink
Update session.py (#441)
Browse files Browse the repository at this point in the history
Format formatted_cost to be outside of the token_cost if else condition.
  • Loading branch information
knivore authored Oct 14, 2024
1 parent 142e50b commit f5e8ec3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions agentops/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,14 @@ def format_duration(start_time, end_time):
token_cost_d = Decimal(0)
else:
token_cost_d = Decimal(token_cost)
formatted_cost = (
"{:.2f}".format(token_cost_d)
if token_cost_d == 0
else "{:.6f}".format(
token_cost_d.quantize(Decimal("0.000001"), rounding=ROUND_HALF_UP)
)

formatted_cost = (
"{:.2f}".format(token_cost_d)
if token_cost_d == 0
else "{:.6f}".format(
token_cost_d.quantize(Decimal("0.000001"), rounding=ROUND_HALF_UP)
)
)

analytics = (
f"Session Stats - "
Expand Down

0 comments on commit f5e8ec3

Please sign in to comment.