-
Notifications
You must be signed in to change notification settings - Fork 157
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
implement OpenAI token usage #150
Conversation
thanks for this! It's a possible design, and it's simple to understand (simpler than requiring to populate context). A few considerations:
|
Yes, letting users do it explicitly would be cleaner and less assumptious.
Thanks for bringing this, I will add a test for this too.
+1 |
great idea @aniketmaurya |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #150 +/- ##
===================================
+ Coverage 79% 80% +1%
===================================
Files 13 13
Lines 933 985 +52
===================================
+ Hits 737 792 +55
+ Misses 196 193 -3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
See comment, we need to keep code readable and this PR makes it less so. See if you can fix it.
Before submitting
What does this PR do?
RIght now we don't provide a way to track prompt tokens and completion tokens and send a dummy value in the response.
This PR will proposes a way to track and update the usage info for
completion_tokens
,prompt_tokens
andtotal_tokens
.Proposal
Return the
prompt_tokens
andcompletion_tokens
along with the generated content and LitServe will automatically update it and send in response.Just added test for the expected flow right now, if you approve @lantiga this proposal then I can update the rest asap.
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃