We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
def display_token_usage(): console = Console() table = Table(box=box.ROUNDED) table.add_column("Model", style="cyan") table.add_column("Input", style="magenta") table.add_column("Output", style="magenta") table.add_column("Total", style="green") table.add_column("% of Context", style="yellow") table.add_column("Cost ($)", style="red") total_input = 0 total_output = 0 grand_total = 0 total_cost = 0 for model, tokens in [ ("Main Model", main_model_tokens), ("Tool Checker", tool_checker_tokens), ("Code Editor", code_editor_tokens), ("Code Execution", code_execution_tokens), ]: total = tokens["input"] + tokens["output"] percentage = (total / MAX_CONTEXT_TOKENS) * 100 input_cost = (tokens["input"] / 1_000_000) * 3.00 output_cost = (tokens["output"] / 1_000_000) * 15.00 model_cost = input_cost + output_cost total_input += tokens["input"] total_output += tokens["output"] grand_total += total total_cost += model_cost table.add_row( model, str(tokens["input"]), str(tokens["output"]), str(total), f"{percentage:.2f}%", f"${model_cost:.3f}", ) total_percentage = (grand_total / MAX_CONTEXT_TOKENS) * 100 table.add_row( "Total", str(total_input), str(total_output), str(grand_total), f"{total_percentage:.2f}%", f"${total_cost:.3f}", style="bold", ) console.print(table) summary_panel = Panel( f"[bold]Total Input Tokens:[/bold] {total_input:,}\n" f"[bold]Total Output Tokens:[/bold] {total_output:,}\n" f"[bold]Grand Total Tokens:[/bold] {grand_total:,}\n" f"[bold]Context Window Usage:[/bold] {total_percentage:.2f}%\n" f"[bold]Total Cost:[/bold] ${total_cost:.3f}", title="Token Usage Summary", border_style="blue", ) console.print(summary_panel)
Pietro Schirano what do you think about this?
The text was updated successfully, but these errors were encountered:
I know you won't realize it but I still think it's so much prettier that way! 😁
Sorry, something went wrong.
Love this idea but % of context doesnt apply on total token count. Let me rework it a bit and i add it into the app
No branches or pull requests
Pietro Schirano what do you think about this?
The text was updated successfully, but these errors were encountered: