Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request improves the way token usage statistics are calculated and logged throughout the
mini-a.jscodebase. The main change is the introduction of a new helper method for robustly computing total token counts, which is now used consistently across summary, response, and fallback handling logic. Additionally, the interaction logging function is made more flexible, and a method to retrieve the instance ID is added.Token statistics calculation and logging:
_getTotalTokensto compute total token usage from stats objects, handling cases wheretotal_tokensmay be missing and falling back to summingprompt_tokensandcompletion_tokens. This method is now used in all places where token metrics are updated, improving consistency and robustness._startInternaland_runChatbotModeto use_getTotalTokens, ensuring that token counts are always computed accurately for normal, low-cost, and fallback model responses. [1] [2] [3] [4] [5] [6]Interaction logging improvements:
defaultInteractionFnto accept an optional callback function (cFn) for custom logging behavior, with a default that preserves previous functionality. [1] [2]API enhancement:
getIdto retrieve the unique ID of aMiniAinstance.