refactor: Move format_tokens function to utils.py

This commit is contained in:
Paul Gauthier (aider) 2024-08-26 15:46:26 -07:00
parent 93e37b60d0
commit bd9e6d7f58
2 changed files with 10 additions and 9 deletions

View file

@ -280,6 +280,14 @@ def find_common_root(abs_fnames):
else:
return safe_abs_path(os.getcwd())
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"
def check_pip_install_extra(io, module, prompt, pip_install_cmd):
try: