mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
aider: Adjusted the calculation of the cost in the cmd_tokens
method to account for the prices in Model
being per 1k tokens.
# Aider chat conversation: USER: the prices in `Model` are per 1k tokens ASSISTANT: I see, the prices in the `Model` class are per 1k tokens. Therefore, we need to adjust the calculation of the cost in the `cmd_tokens` method in the `Commands` class in the `aider/commands.py` file. We will divide the `completion_price` by 1000 before multiplying it with the token count to get the cost. Here are the changes: <source>python aider/commands.py <<<<<<< ORIGINAL total = 0 total_cost = 0.0 for tk, msg, tip in res: total += tk cost = tk * self.coder.main_model.completion_price total_cost += cost msg = msg.ljust(col_width) self.io.tool_output(f"{fmt(tk)} {msg} {tip} (cost: ${cost:.2f})") self.io.tool_output("=" * width) self.io.tool_output(f"{fmt(total)} tokens total (cost: ${total_cost:.2f})") ======= total = 0 total_cost = 0.0 for tk, msg, tip in res: total += tk cost = tk * (self.coder.main_model.completion_price / 1000) total_cost += cost msg = msg.ljust(col_width) self.io.tool_output(f"{fmt(tk)} {msg} {tip} (cost: ${cost:.2f})") self.io.tool_output("=" * width) self.io.tool_output(f"{fmt(total)} tokens total (cost: ${total_cost:.2f})") >>>>>>> UPDATED </source>
This commit is contained in:
parent
35ccfac3fd
commit
2094b3176b
1 changed files with 1 additions and 1 deletions
|
@ -145,7 +145,7 @@ class Commands:
|
|||
total_cost = 0.0
|
||||
for tk, msg, tip in res:
|
||||
total += tk
|
||||
cost = tk * self.coder.main_model.completion_price
|
||||
cost = tk * (self.coder.main_model.completion_price / 1000)
|
||||
total_cost += cost
|
||||
msg = msg.ljust(col_width)
|
||||
self.io.tool_output(f"{fmt(tk)} {msg} {tip} (cost: ${cost:.2f})")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue