Add token and cost calculation to message completion

This commit is contained in:
Paul Gauthier 2024-07-28 15:53:34 -03:00 committed by Paul Gauthier (aider)
parent f81acb839c
commit 57964f1e79

View file

@ -1137,6 +1137,8 @@ class Coder:
if interrupted: if interrupted:
raise KeyboardInterrupt raise KeyboardInterrupt
self.calculate_and_show_tokens_and_cost(messages, completion)
def show_send_output(self, completion): def show_send_output(self, completion):
if self.verbose: if self.verbose:
print(completion) print(completion)
@ -1169,8 +1171,6 @@ class Coder:
self.io.tool_error(show_content_err) self.io.tool_error(show_content_err)
raise Exception("No data found in LLM response!") raise Exception("No data found in LLM response!")
self.calculate_and_show_tokens_and_cost(completion)
show_resp = self.render_incremental_response(True) show_resp = self.render_incremental_response(True)
if self.show_pretty(): if self.show_pretty():
show_resp = Markdown( show_resp = Markdown(
@ -1228,7 +1228,6 @@ class Coder:
sys.stdout.flush() sys.stdout.flush()
yield text yield text
self.calculate_and_show_tokens_and_cost()
def live_incremental_response(self, final): def live_incremental_response(self, final):
show_resp = self.render_incremental_response(final) show_resp = self.render_incremental_response(final)