-
Notifications
You must be signed in to change notification settings - Fork 16k
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
Community : Add OpenAI prompt caching and reasoning tokens tracking #27135
Community : Add OpenAI prompt caching and reasoning tokens tracking #27135
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
Its been a week, can you review this? @baskaryan @efriis @eyurtsev |
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.
unfortunately this is a breaking change due to the removal of is_completion
. Will wait for @baskaryan to return from vacation to think about how we want to handle.
@efriis will it be okay, if I revert it and use another Boolean is_cached_prompt ? |
@efriis @baskaryan I am waiting for this PR to be processed. Could you provide an update on its progress? |
# Conflicts: # libs/community/langchain_community/callbacks/openai_info.py
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.
@baskaryan @efriis I made some modifications here such that:
- Token type (prompt, completion, cached) is represented with an enum.
is_completion
is deprecated in favor of this enum. Passingis_completion=True
will generate a warning.
Warnings will only be generated for users if they are using get_openai_token_cost_for_model
or standardize_model_name
with is_completion=True
directly. These functions are not in our docs. Using the callback as documented won't generate a deprecation warning.
lmk if any thoughts.
Added Token tracking for OpenAI's prompt caching and reasoning tokens
Costs updated from https://openai.com/api/pricing/
usage example
Output