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

[FrontEnd] Display API cost and token usage in frontend #7099

Merged
merged 10 commits into from
Mar 21, 2025

Conversation

AutoLTX
Copy link
Contributor

@AutoLTX AutoLTX commented Mar 4, 2025

  • This change is worth documenting at https://docs.all-hands.dev/
  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

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.
This will expose API cost and usage info to customers in on-demand mode.

  • Expose cost and usage info in default mode.
  • User can click the hide cost button and hide the Cost and Usage. Then chat will show as original and cover all left channel.
    Some screenshots:
    Expose mode in default:
image image Hide mode: image

Link of any specific issues this addresses.
#5257

@AutoLTX
Copy link
Contributor Author

AutoLTX commented Mar 4, 2025

This PR needs to wait for backend PR #7082 merge first. And I may still change some details of the PR. But the inital design is finished. Let's make sure it can meet your requirement first!

Tagging reviewers for best design discussion: @neubig, @rbren, @enyst, @amanape. All the screenshots
are already uploaded in the PR description.

Now I use tilin/testFrontendE2E branch to test and get the screenshots. Feel free to try it if you need it.

@enyst enyst changed the title [FrontEnd][Waiting for backend PR merged, open for best design discussion in parallel] Display API cost and token usage in frontend [FrontEnd] Display API cost and token usage in frontend Mar 4, 2025
@rbren
Copy link
Collaborator

rbren commented Mar 13, 2025

@AutoLTX thanks for taking this on!

I'd like to get some fuller designs done, but for now let's put the button inside the conversation card's context menu, and then show the costs in a modal

Does that work for you?

Screenshot 2025-03-13 at 11 51 49 AM

@amanape amanape self-requested a review March 13, 2025 16:05
@amanape amanape self-assigned this Mar 13, 2025
@AutoLTX
Copy link
Contributor Author

AutoLTX commented Mar 13, 2025

@rbren Certainly! I will follow your advice. And I guarantee to complete it before this weekend
By the way, do you think it's ok to expose accumulated_cost, total_tokens, prompt_tokens, and completion tokens in a window directly? Or you prefer just show cost in the window, and click some buttons like "detailed" and show usage related things?

@rbren
Copy link
Collaborator

rbren commented Mar 13, 2025

Awesome! Let's just show everything inside the pop-up modal

@AutoLTX AutoLTX force-pushed the tilin/costFrontEnd branch from 79432e6 to a8b33de Compare March 16, 2025 18:48
@AutoLTX
Copy link
Contributor Author

AutoLTX commented Mar 16, 2025

Hi, @amanape.I've update the code to align with @rbren 's requirement. Now all the CI passed. Could you please review it?
Latest result:
image
image
By the way, do we need to update the doc/release note to show the display cost feature?

@rbren
Copy link
Collaborator

rbren commented Mar 17, 2025

@AutoLTX good work! We have an existing modal UI though, which should look nicer (e.g. for the close button). @amanape can probably point you in the right direction

@AutoLTX
Copy link
Contributor Author

AutoLTX commented Mar 17, 2025

Thanks for remind. @rbren I checked the code and use baseModal now. The window will be closed when users use "esc" or click other space of the website. I don't add additional close button.
image
image

@AutoLTX AutoLTX mentioned this pull request Mar 19, 2025
1 task
@AutoLTX
Copy link
Contributor Author

AutoLTX commented Mar 19, 2025

Gently ping, @amanape Could you please review this PR?

@amanape
Copy link
Member

amanape commented Mar 19, 2025

Will do soon, hopefully later today.

@turian
Copy link
Contributor

turian commented Mar 20, 2025

Related: #7107 #7105 #7102

@turian
Copy link
Contributor

turian commented Mar 20, 2025

@AutoLTX How difficult would it be to include this information in the PR comments pushed ?

Copy link
Member

@amanape amanape left a comment

Choose a reason for hiding this comment

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

LGTM! Made a few small changes, but awesome work overall. Thanks!

@amanape amanape enabled auto-merge (squash) March 21, 2025 20:17
@amanape amanape merged commit 3bc52ca into All-Hands-AI:main Mar 21, 2025
16 checks passed
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.

4 participants