Feature/context token counter #608
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added a Context token counter to the task header. It is a minimal addition that uses the same counting logic as the input and output tokens counter. It takes the total input tokens from the last message, and adds in the output tokens. This is updated every time a new message is received from the API, and covers against edge cases such as failed requests.
Type of change
How Has This Been Tested?
Tested it manually in debugging mode, added logic to prevent mistakes in edge cases.
Checklist:
Additional context
Related Issues
Reviewers
Important
Add context token counter to task header, updating with each API message in
getApiMetrics.tsand displaying inTaskHeader.tsx.contextTokenstoApiMetricsingetApiMetrics.ts, calculated as the sum oftokensInandtokensOutfrom the lastapi_req_startedmessage.contextTokensinTaskHeader.tsxto display the total context tokens in the task header.contextTokenstoTaskHeaderinChatView.tsx.contextTokensinTaskHeader.tsxunder the "Context" label.This description was created by
for 97fe13d. It will automatically update as commits are pushed.