From bba0cc8dc5d14fb7739d1fa580b583899f46bc2d Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Sat, 4 Jan 2025 12:09:48 -0800 Subject: [PATCH] feat: show token count in command output confirmation prompt --- aider/commands.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 5cb346585..73e13d511 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -918,11 +918,16 @@ class Commands: if combined_output is None: return - # tokenize the output, and ask "Add xx k-tokens of command output to the chat?" # ai! + # Calculate token count of output + token_count = self.coder.main_model.token_count(combined_output) + k_tokens = token_count / 1000 + if add_on_nonzero_exit: add = exit_status != 0 else: - add = self.io.confirm_ask("Add command output to the chat?") + add = self.io.confirm_ask( + f"Add {k_tokens:.1f}k tokens of command output to the chat?" + ) if add: num_lines = len(combined_output.strip().splitlines())