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

fix(llm): cost metrics calculation for unsupport litellm prefix #6022

Merged
merged 4 commits into from
Jan 4, 2025

Conversation

xingyaoww
Copy link
Collaborator

@xingyaoww xingyaoww commented Jan 4, 2025

End-user friendly description of the problem this fixes or functionality that this introduces

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

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


Link of any specific issues this addresses


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:40ca3d5-nikolaik   --name openhands-app-40ca3d5   docker.all-hands.dev/all-hands-ai/openhands:40ca3d5

@xingyaoww xingyaoww requested a review from enyst January 4, 2025 03:29
if cost is None:
cost = float(
_hidden_params.get('additional_headers', {}).get(
'llm_provider-x-litellm-response-cost', 0.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

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 🤔

Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double checked again to make sure!

image

Copy link
Collaborator

@enyst enyst left a 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 😅)

@xingyaoww xingyaoww enabled auto-merge (squash) January 4, 2025 17:52
@xingyaoww xingyaoww merged commit aaff3dd into main Jan 4, 2025
19 checks passed
@xingyaoww xingyaoww deleted the xw/fix-metric branch January 4, 2025 18:09
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