Add usage reporting to the Coder class

This commit is contained in:
Paul Gauthier 2024-07-28 15:59:59 -03:00 committed by Paul Gauthier (aider)
parent afe50cab3d
commit fe50400bf3

View file

@ -851,6 +851,7 @@ class Coder:
else: else:
self.mdstream = None self.mdstream = None
self.usage_report = None
exhausted = False exhausted = False
interrupted = False interrupted = False
try: try:
@ -892,6 +893,9 @@ class Coder:
self.partial_response_content = self.get_multi_response_content(True) self.partial_response_content = self.get_multi_response_content(True)
self.multi_response_content = "" self.multi_response_content = ""
if self.usage_report:
self.io.tool_output(self.usage_report)
if exhausted: if exhausted:
self.show_exhausted_error() self.show_exhausted_error()
self.num_exhausted_context_windows += 1 self.num_exhausted_context_windows += 1
@ -1256,7 +1260,7 @@ class Coder:
tokens += f", ${cost:.6f} cost" tokens += f", ${cost:.6f} cost"
self.total_cost += cost self.total_cost += cost
self.io.tool_output(tokens) self.usage_report = tokens
def get_multi_response_content(self, final=False): def get_multi_response_content(self, final=False):
cur = self.multi_response_content cur = self.multi_response_content