Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parsing for detailed token usage information #282

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

e-max
Copy link
Contributor

@e-max e-max commented Oct 17, 2024

OpenAI API returns detailed information about token usage. This PR parses such info.
Reference: https://platform.openai.com/docs/api-reference/chat/object#chat/object-usage

This update adds functionality to parse the detailed token usage data returned by the OpenAI API.
Reference: https://platform.openai.com/docs/api-reference/chat/object#chat/object-usage
@64bit
Copy link
Owner

64bit commented Oct 18, 2024

Nice, thank you for the PR!

@64bit 64bit merged commit 6858399 into 64bit:main Oct 18, 2024
@64bit
Copy link
Owner

64bit commented Oct 18, 2024

I would have released it but examples/completions is failing with this change, do you mind sending a fix please?

Error: JSONDeserialize(Error("missing field `prompt_tokens_details`", line: 18, column: 3))

@64bit 64bit mentioned this pull request Oct 18, 2024
@e-max
Copy link
Contributor Author

e-max commented Oct 18, 2024

I am sorry, I should have checked on legacy models as well. #284

ifsheldon pushed a commit to ifsheldon/async-openai-wasm that referenced this pull request Nov 23, 2024
This update adds functionality to parse the detailed token usage data returned by the OpenAI API.
Reference: https://platform.openai.com/docs/api-reference/chat/object#chat/object-usage

(cherry picked from commit 6858399)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants