mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 18:25:00 +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()
|
self.cache_warming_thread.cancel()
|
||||||
|
|
||||||
def warm_cache_worker():
|
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
|
time.sleep(20) # 290 == 4 minutes and 50 seconds
|
||||||
try:
|
try:
|
||||||
completion = litellm.completion(
|
completion = litellm.completion(
|
||||||
|
@ -1013,7 +1013,16 @@ class Coder:
|
||||||
cache_hit_tokens = getattr(
|
cache_hit_tokens = getattr(
|
||||||
completion.usage, "prompt_cache_hit_tokens", 0
|
completion.usage, "prompt_cache_hit_tokens", 0
|
||||||
) or getattr(completion.usage, "cache_read_input_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.")
|
self.io.tool_output("Stopped warming.")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue