-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
fix(llm): cost metrics calculation for unsupport litellm prefix #6022
Conversation
if cost is None: | ||
cost = float( | ||
_hidden_params.get('additional_headers', {}).get( | ||
'llm_provider-x-litellm-response-cost', 0.0 |
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.
Is this the header name, or just x-litellm-response-cost
?
https://github.com/BerriAI/litellm/blob/3230c902c9d9c4c933773e946b744965573a14f9/litellm/proxy/proxy_server.py#L738
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.
yeah i think this is the actual key in that dict 🤔
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.
Strange! 😅
OK, let's go with it
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.
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 reasonable, thanks!
(I think sometime we could move this to the logging mixin or something, we seem to have more and more code unrelated to the main purpose of this class to keep track of in the same place 😅)
End-user friendly description of the problem this fixes or functionality that this introduces
Give a summary of what the PR does, explaining any non-trivial design decisions
Currently, our metric cost calculation doesn't work if the model is served through LiteLLM proxy.
This PR
llm_provider-x-litellm-response-cost
from the litellm proxy response https://docs.litellm.ai/docs/proxy/cost_tracking#how-to-track-spend-with-litellmlitellm_proxy/
prefix for cost) -- so as long as the model name is the same, it will get the cost correctly.Link of any specific issues this addresses
To run this PR locally, use the following command: