-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Display API costs in frontend #5257
Comments
An attempt was made to automatically fix this issue, but it was unsuccessful. A branch named 'openhands-fix-issue-5257' has been created with the attempted changes. You can view the branch here. Manual intervention may be required. |
Based on a follow-up discussion with @rbren , we should maybe have statistics put in a separate window to prevent clutter in the main interface. But the window could be opened with a button. |
A potential fix has been generated and a draft PR #5323 has been created. Please review the changes. |
I’d like this. I can monitor through the api dashboards but this would be really convenient |
Just a note that we got a comment on this in our user survey, adding a comment here to note for up-prioritization. |
I'd like to pick this one. Could you please assign it to me? @neubig |
@AutoLTX I've assigned this to you. Please let us know if you need any help! |
Additionally, this doesn't look like a just front-end feature. (Which means frontend only need to get cost number from backend REST API). This looks like a E2E feature. Currently, I checked the backend code and found cost relate logic leveraging litellmProxy here The logic is related to LLM completion. This part is connected using WebSocket, not RESTAPI. So, it seems we need to use observation to pass through the result. This will cause great effort in backend side. I prepare to use a separate observation type/ add additional fields in chat observation to cover the scenario. |
I think that... is a good question, @AutoLTX . But wait, I seem to recall there is something we already did! Please take a look at this PR, specifically: That field in |
Hi, @enyst Thanks for your tips! The llm_metrics is the parameter of event. As event is the base class of both Action and Observation. So I decide to pass the llm_metric to frontend and use accumulate cost to tracking the cost. I checked and confirmed (By using many logs). The llm_metric is updated successfully after the function "update_state_after_step". Then I go throught the backend logic, founding that the observation generation process is in "action_execution_client.py". Noticing that in action_execution_client.py, many actions are newly generated(eg: run->CmdRunAction). So totally they won't pass through the llm_metric. Changing each action's behavior will cost too much. Then I decided to take an alternate way. I saw the llm_metrics is recorded in the global parameter of self.state.local_metrics in agent_controller.py. So I updated the observation.metric in _handle_observation. This works and I can see the cost from logs. However, I found in the final event stream passed by websocket oh_event. It still didn't have llm_metric.(It seems lost before event_to_dict in backend side) I'm still trying to narrow down and find the root cause. It would be very helpful and accelerate my debugging process if you are familiar with the logic between generating observation-> finally pass it in the event stream and have any insight of it. Draft PR link(This is not final version and I just use it to make sure e2e work. Please ignore the ugly frontend temporarily. Just see the backend logic. Thanks!): https://github.com/All-Hands-AI/OpenHands/pull/6823/files#diff-1e082f415afb40de1d5c2a3fa327326225e1da28a142ad89c9524109f35fb36e This is my first onboarding issue for OpenHands and I have limited context for it, the speed is a little bit slow. Sorry for too many questions and thanks for your patient. 😂 |
What problem or use case are you trying to solve?
Direct communication from a user:
Describe the UX of the solution you'd like
It'd be good to give an idea of (1) how much the whole agent trajectory cost, and (2) how much the past few steps cost.
Do you have thoughts on the technical implementation?
The text was updated successfully, but these errors were encountered: