Skip to content

Commit

Permalink
5.8.7 update openai consuming calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-X-Net committed Nov 15, 2023
1 parent 791bac3 commit fb5a760
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions code/default/x_tunnel/local/openai_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ def handle_openai(method, path, headers, req_body, sock):
data = content

dat = json.loads(data)
total_tokens = dat["usage"]["total_tokens"]
cost = total_tokens * openai_chat_token_price
g.openai_balance -= cost
consumed_balance = dat["usage"]["consumed_balance"]
g.openai_balance -= consumed_balance
except Exception as e1:
xlog.exception("cal tokens err:%r", e1)

Expand Down

0 comments on commit fb5a760

Please sign in to comment.