mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 19:24:59 +00:00
refactor: Move format_tokens function to utils.py
This commit is contained in:
parent
93e37b60d0
commit
bd9e6d7f58
2 changed files with 10 additions and 9 deletions
|
@ -22,7 +22,8 @@ import git
|
||||||
from rich.console import Console, Text
|
from rich.console import Console, Text
|
||||||
from rich.markdown import Markdown
|
from rich.markdown import Markdown
|
||||||
|
|
||||||
from aider import __version__, models, prompts, urls, utils
|
from aider import __version__, models, prompts, urls
|
||||||
|
from aider.utils import format_tokens, utils
|
||||||
from aider.commands import Commands
|
from aider.commands import Commands
|
||||||
from aider.history import ChatSummary
|
from aider.history import ChatSummary
|
||||||
from aider.io import ConfirmGroup, InputOutput
|
from aider.io import ConfirmGroup, InputOutput
|
||||||
|
@ -1488,14 +1489,6 @@ class Coder:
|
||||||
|
|
||||||
self.message_tokens_received += completion_tokens
|
self.message_tokens_received += completion_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"
|
|
||||||
|
|
||||||
tokens_report = f"Tokens: {format_tokens(self.message_tokens_sent)} sent"
|
tokens_report = f"Tokens: {format_tokens(self.message_tokens_sent)} sent"
|
||||||
|
|
||||||
if cache_write_tokens:
|
if cache_write_tokens:
|
||||||
|
|
|
@ -280,6 +280,14 @@ def find_common_root(abs_fnames):
|
||||||
else:
|
else:
|
||||||
return safe_abs_path(os.getcwd())
|
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):
|
def check_pip_install_extra(io, module, prompt, pip_install_cmd):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue