mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
feat: Add progress indicator and format cached tokens in warm_cache_worker
This commit is contained in:
parent
8319df775e
commit
a6ff08b2c5
1 changed files with 11 additions and 2 deletions
|
@ -996,7 +996,7 @@ class Coder:
|
|||
self.cache_warming_thread.cancel()
|
||||
|
||||
def warm_cache_worker():
|
||||
for _ in range(self.num_cache_warming_pings):
|
||||
for i in range(self.num_cache_warming_pings):
|
||||
time.sleep(20) # 290 == 4 minutes and 50 seconds
|
||||
try:
|
||||
completion = litellm.completion(
|
||||
|
@ -1013,7 +1013,16 @@ class Coder:
|
|||
cache_hit_tokens = getattr(
|
||||
completion.usage, "prompt_cache_hit_tokens", 0
|
||||
) or getattr(completion.usage, "cache_read_input_tokens", 0)
|
||||
self.io.tool_output(f"Warmed {cache_hit_tokens} cached tokens.")
|
||||
|
||||
def format_tokens(count):
|
||||
if count < 1000:
|
||||
return f"{count}"
|
||||
elif count < 10000:
|
||||
return f"{count / 1000:.1f}k"
|
||||
else:
|
||||
return f"{round(count / 1000)}k"
|
||||
|
||||
self.io.tool_output(f"Warmed {format_tokens(cache_hit_tokens)} cached tokens. ({i+1}/{self.num_cache_warming_pings})")
|
||||
|
||||
self.io.tool_output("Stopped warming.")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue