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

🗼 Feature request: OpenAI tokens usage information returned in add and query methods. #574

Closed
Panczo opened this issue Sep 6, 2023 · 3 comments · Fixed by #1392
Closed
Labels
enhancement New feature or request medium Medium difficulty

Comments

@Panczo
Copy link

Panczo commented Sep 6, 2023

🚀 The feature

I was looking at docs and previous issues but couldn't find any information about consumed OpenAI tokens.
According to the OpenAI documentation, they return following information in they response:

  "usage": {
    "prompt_tokens": 5,
    "completion_tokens": 7,
    "total_tokens": 12
  }

It'd be very useful to have such information, as right now I cannot track/measure programmatically consumed OpenAI tokens.
So I imagine that if I'll put some option to query or add config, data about usage will be returned in the response, something like below:

result = naval_chat_bot.add("https://www.youtube.com/watch?v=3qHkcs3kG44", config=add_config)
result['source'] => some source id
result['usage'] => usage data info

result = test_chat_bot.query('some happy little query', )
result['response_message'] => 'generated response'
result['usage'] => usage data info

It can be even simplified using some kind of proxy flag, so the whole OpenAI response will be returned.

Motivation, pitch

I'm working on a web app, where each user can have his own sources db. I don't want to force someone to put/use his own OpenAI api key, instead I want to control user tokens usage programmatically.

@Panczo Panczo changed the title 💵 OpenAI tokens usage information returned in add and query methods. 🗼 OpenAI tokens usage information returned in add and query methods. Sep 6, 2023
@Panczo Panczo changed the title 🗼 OpenAI tokens usage information returned in add and query methods. 🗼 Feature request: OpenAI tokens usage information returned in add and query methods. Sep 6, 2023
@cachho
Copy link
Contributor

cachho commented Sep 11, 2023

Good idea, this should definitely be on the list of things to add, however this isn't a quick thing to introduce so I must ask for some patience. thanks.

@Panczo
Copy link
Author

Panczo commented Mar 17, 2024

Hi @cachho any news about this feature?

@Dev-Khant Dev-Khant added enhancement New feature or request medium Medium difficulty labels Jun 2, 2024
@Panczo
Copy link
Author

Panczo commented Jul 7, 2024

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request medium Medium difficulty
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants