mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
feat: Track total tokens and use in benchmark stats
This commit is contained in:
parent
a98b531bcc
commit
5090f28151
2 changed files with 15 additions and 4 deletions
|
@ -108,8 +108,6 @@ class Coder:
|
||||||
partial_response_content = ""
|
partial_response_content = ""
|
||||||
commit_before_message = []
|
commit_before_message = []
|
||||||
message_cost = 0.0
|
message_cost = 0.0
|
||||||
message_tokens_sent = 0
|
|
||||||
message_tokens_received = 0
|
|
||||||
add_cache_headers = False
|
add_cache_headers = False
|
||||||
cache_warming_thread = None
|
cache_warming_thread = None
|
||||||
num_cache_warming_pings = 0
|
num_cache_warming_pings = 0
|
||||||
|
@ -128,6 +126,8 @@ class Coder:
|
||||||
from_coder=None,
|
from_coder=None,
|
||||||
summarize_from_coder=True,
|
summarize_from_coder=True,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
|
||||||
|
|
||||||
):
|
):
|
||||||
import aider.coders as coders
|
import aider.coders as coders
|
||||||
|
|
||||||
|
@ -175,6 +175,8 @@ class Coder:
|
||||||
commands=from_coder.commands.clone(),
|
commands=from_coder.commands.clone(),
|
||||||
total_cost=from_coder.total_cost,
|
total_cost=from_coder.total_cost,
|
||||||
ignore_mentions=from_coder.ignore_mentions,
|
ignore_mentions=from_coder.ignore_mentions,
|
||||||
|
total_tokens_sent=from_coder.total_tokens_sent,
|
||||||
|
total_tokens_received=from_coder.total_tokens_received,
|
||||||
file_watcher=from_coder.file_watcher,
|
file_watcher=from_coder.file_watcher,
|
||||||
)
|
)
|
||||||
use_kwargs.update(update) # override to complete the switch
|
use_kwargs.update(update) # override to complete the switch
|
||||||
|
@ -327,6 +329,8 @@ class Coder:
|
||||||
chat_language=None,
|
chat_language=None,
|
||||||
detect_urls=True,
|
detect_urls=True,
|
||||||
ignore_mentions=None,
|
ignore_mentions=None,
|
||||||
|
total_tokens_sent=0,
|
||||||
|
total_tokens_received=0,
|
||||||
file_watcher=None,
|
file_watcher=None,
|
||||||
auto_copy_context=False,
|
auto_copy_context=False,
|
||||||
auto_accept_architect=True,
|
auto_accept_architect=True,
|
||||||
|
@ -373,6 +377,10 @@ class Coder:
|
||||||
self.need_commit_before_edits = set()
|
self.need_commit_before_edits = set()
|
||||||
|
|
||||||
self.total_cost = total_cost
|
self.total_cost = total_cost
|
||||||
|
self.total_tokens_sent = total_tokens_sent
|
||||||
|
self.total_tokens_received = total_tokens_received
|
||||||
|
self.message_tokens_sent = 0
|
||||||
|
self.message_tokens_received = 0
|
||||||
|
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
self.abs_fnames = set()
|
self.abs_fnames = set()
|
||||||
|
@ -2057,6 +2065,9 @@ class Coder:
|
||||||
if not self.usage_report:
|
if not self.usage_report:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.total_tokens_sent += self.message_tokens_sent
|
||||||
|
self.total_tokens_received += self.message_tokens_received
|
||||||
|
|
||||||
self.io.tool_output(self.usage_report)
|
self.io.tool_output(self.usage_report)
|
||||||
|
|
||||||
prompt_tokens = self.message_tokens_sent
|
prompt_tokens = self.message_tokens_sent
|
||||||
|
|
|
@ -957,8 +957,8 @@ def run_test_real(
|
||||||
indentation_errors=indentation_errors,
|
indentation_errors=indentation_errors,
|
||||||
lazy_comments=lazy_comments, # Add the count of pattern matches to the results
|
lazy_comments=lazy_comments, # Add the count of pattern matches to the results
|
||||||
reasoning_effort=reasoning_effort,
|
reasoning_effort=reasoning_effort,
|
||||||
prompt_tokens=coder.message_tokens_sent,
|
prompt_tokens=coder.total_tokens_sent,
|
||||||
completion_tokens=coder.message_tokens_received,
|
completion_tokens=coder.total_tokens_received,
|
||||||
thinking_tokens=thinking_tokens,
|
thinking_tokens=thinking_tokens,
|
||||||
chat_hashes=list(
|
chat_hashes=list(
|
||||||
zip(
|
zip(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue