Skip to content

Add chat session token usage #8619

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

Merged
merged 7 commits into from
Jul 24, 2025
Merged

Add chat session token usage #8619

merged 7 commits into from
Jul 24, 2025

Conversation

timtmok
Copy link
Contributor

@timtmok timtmok commented Jul 22, 2025

Address #8472

Adds a container above the chat input for displaying total token usage. A preference listener was added so that the chat view can re-render the token usage for messages and session.

The echo model has also been fixed. It would only return the beginning of the message history. It returns the second last message (the last item is the context).

A couple of e2e tests have been added for basic checks.

image

Release Notes

New Features

Bug Fixes

  • N/A

QA Notes

I assume no other Assistant tests send multiple messages to the echo provider. But this should be possible now and it will echo the message that was sent.

Copy link

github-actions bot commented Jul 22, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

@timtmok timtmok force-pushed the 8472-chat-session-usage branch 2 times, most recently from be5d729 to 1d8585d Compare July 23, 2025 15:42
timtmok added 6 commits July 23, 2025 16:10
Updates chat history when setting changes
Fix echo model echoing the first message on subsequent responses
@timtmok timtmok force-pushed the 8472-chat-session-usage branch from 3f67dc8 to 2a1e1c3 Compare July 23, 2025 20:10
@timtmok timtmok marked this pull request as ready for review July 23, 2025 20:52
@timtmok timtmok requested a review from sharon-wang July 23, 2025 20:52
Copy link
Member

@sharon-wang sharon-wang left a comment

Choose a reason for hiding this comment

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

Nice, this is working great for me! I'm seeing a running total for tokens in the chat session, even when switching between providers. Toggling the setting on/off shows/hides the token counts as expected, without having to restart Positron 👍

Maybe one question for the future: how might we want to breakdown chat session token usage when the user toggles between different models and providers within the same session?

@timtmok
Copy link
Contributor Author

timtmok commented Jul 24, 2025

Nice, this is working great for me! I'm seeing a running total for tokens in the chat session, even when switching between providers. Toggling the setting on/off shows/hides the token counts as expected, without having to restart Positron 👍

Maybe one question for the future: how might we want to breakdown chat session token usage when the user toggles between different models and providers within the same session?

I think we'll have to see how common it is for a user to switch providers within a session. At least for now, the chat metadata does record the model and provider so we should be able to group it by those facets.

@timtmok timtmok merged commit d6f7859 into main Jul 24, 2025
12 checks passed
@timtmok timtmok deleted the 8472-chat-session-usage branch July 24, 2025 17:39
@github-actions github-actions bot locked and limited conversation to collaborators Jul 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants