This pull request adds a new --token-usage flag (with a shorthand -t option) to the program, allowing users to see the token usage information when making requests to the API. This flag enables the program to display the number of prompt tokens, completion tokens, and total tokens used by the request.
Changes Made:
Added both a long flag --token-usage and a short flag -t to the program for reporting token usage.
Added logic to check for the --token-usage flag in the program. If the flag is present and the response contains token usage data, the program will now extract and display it in the console using console.error.
The relevant data is extracted from chunk?.x_groq?.usage in the response, following GROQ API's response structure.
Updated the README.md file to document the new --token-usage (-t) option.
Notes:
No breaking changes were introduced in this pull request.
This PR closes #10 by adding the requested token usage option.
Please let me know if any there are any additional changes required.
Thanks for pointing out the required changes, I have committed some new changes to the branch, please review and suggest if this needs any more changes.
Description:
This pull request adds a new
--token-usage
flag (with a shorthand-t
option) to the program, allowing users to see the token usage information when making requests to the API. This flag enables the program to display the number of prompt tokens, completion tokens, and total tokens used by the request.Changes Made:
--token-usage
and a short flag-t
to the program for reporting token usage.--token-usage
flag in the program. If the flag is present and the response contains token usage data, the program will now extract and display it in the console usingconsole.error
.chunk?.x_groq?.usage
in the response, following GROQ API's response structure.--token-usage (-t)
option.Notes:
Please let me know if any there are any additional changes required.