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

[feat] add remaining token counter in the chat view #4253

Closed

Conversation

PriNova
Copy link
Contributor

@PriNova PriNova commented May 22, 2024

Description

This PR introduces a new feature that displays the remaining token counts for chat, user, and enhanced token types in the chat view. This enhancement aims to provide users with real-time visibility into their token usage, helping them manage their token allocation more effectively.

Changes

  • Updated the TokenCounter class to expose a new method, getRemainingTokens(), which returns an object containing the remaining token counts for each token type.
  • Modified the SimpleChatPanelProvider to:
    • Retrieve the remaining token counts from the TokenCounter instance after building the prompt.
    • Send the remaining token counts to the webview using the postMessage method.
  • Updated the prompt building logic to return both the PromptInfo and TokenCounter instances.
  • Added a new 'remainingTokens' message type to the extension-webview communication protocol to facilitate the transfer of token counts.
  • Created a new TokenIndicators component that displays the remaining token counts in the chat view UI.
  • Integrated the TokenIndicators component into the Chat component, populating it with the token counts received from the extension.
  • Added styling for the TokenIndicators component to ensure a visually appealing and intuitive user experience.

Benefits

  • Users can now see their remaining token counts for each token type directly in the chat view.
  • The real-time display of token usage helps users make informed decisions about their token allocation and usage.
  • The integration of token indicators enhances the overall user experience and provides valuable insights into token consumption.

Screenshots

Screenshot 2024-05-22 145051

Checklist

  • Tested the changes manually
  • Updated relevant documentation (if applicable)
  • Followed the project's coding conventions and style guidelines
  • Performed a self-review of the code
  • Wrote clear and concise commit messages following the conventional commit format

Please review this PR and provide any feedback or suggestions for improvement. Let me know if you have any questions or concerns.

Test plan

  • Manually tested the feature by engaging in chat conversations and verifying that the token indicators update accurately based on the token usage.
  • Ensured that the token counts are correctly retrieved from the TokenCounter and propagated to the webview.
  • Verified that the TokenIndicators component renders properly and displays the expected token counts.

PriNova and others added 13 commits May 22, 2024 16:24
- Update TokenCounter to expose a method for retrieving remaining token counts
- Modify SimpleChatPanelProvider to:
  - Retrieve remaining token counts from TokenCounter after building the prompt
  - Send remaining token counts to the webview via postMessage
- Update prompt building logic to return both PromptInfo and TokenCounter instances
- Add 'remainingTokens' message type to extension-webview communication protocol
- Create TokenIndicators component to display remaining token counts in the UI
- Add TokenIndicators to the Chat component, populated with counts received from the extension
- Add styling for the TokenIndicators component
@PriNova PriNova closed this May 25, 2024
@PriNova PriNova deleted the prinova/feat_remainingTokenCounter branch May 25, 2024 08:39
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.

None yet

5 participants