MehmetMHY / cha

A simple CLI chat tool to easily interface with OpenAI's models
MIT License
38 stars 3 forks source link

Added "stats" option for Total Token and Cost Calculation per session #11

Closed MehmetMHY closed 5 months ago

MehmetMHY commented 5 months ago

About

Added the "stats" option that calculate/estimate the total number of tokens and cost you generated per session. By default, this option is disabled unless you enable it as an argument.

⚠️ Warning

The returned token and cost values are estimated. It's not perfect. I tried to make it over estimate in the worse case. To see the exact cost of your usage, refer to OpenAI's usage portal.

Demo

> cha --stats -tp "false" -m "gpt-4"

User: Hello

Hi! How can I assist you today?

User: ^C

SESSION'S STATS (TEXT-BASED):
- LLM Model Name: gpt-4
~ Total Input+Output Tokens: 17 + 10 = 27
~ Total Input+Output Cost: $0.00 + $0.00 = $0.00111