fix: use Console().print for token usage and remove spurious space in…#76
Open
aryanputta wants to merge 1 commit into
Open
fix: use Console().print for token usage and remove spurious space in…#76aryanputta wants to merge 1 commit into
aryanputta wants to merge 1 commit into
Conversation
… astream
_print_usage called print() with rich markup syntax, which plain print() renders as literal text. Replaced with Console().print() so the markup is actually interpreted. Also added the missing Console import. In astream, final_output += f" {content}" prepended a space before every token. Changed to final_output += content. Fixes nasa-jpl#75.
Closed
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.
Fixes #75
Two bugs in src/rosa/rosa.py are fixed in this PR.
Purpose
_print_usage was calling print() with rich markup strings. Plain print() does not interpret rich markup, so show_token_usage=True printed literal bracket tags instead of formatted text. Replaced with Console().print() and added the missing Console import from rich.console.
In astream, the token accumulation read final_output += f" {content}", prepending a space before every token. When no on_chain_end event provides a final output, the fallback string recorded to chat history started with a leading space. Changed to final_output += content.
Proposed Changes
Issues
Testing