mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
fix: Handle missing model info values gracefully
This commit is contained in:
parent
72572f06d9
commit
e48fecee14
3 changed files with 6 additions and 8 deletions
|
@ -852,7 +852,7 @@ class Coder:
|
|||
|
||||
final = messages[-1]
|
||||
|
||||
max_input_tokens = self.main_model.info.get("max_input_tokens")
|
||||
max_input_tokens = self.main_model.info.get("max_input_tokens") or 0
|
||||
# Add the reminder prompt if we still have room to include it.
|
||||
if (
|
||||
max_input_tokens is None
|
||||
|
@ -1011,10 +1011,10 @@ class Coder:
|
|||
output_tokens = 0
|
||||
if self.partial_response_content:
|
||||
output_tokens = self.main_model.token_count(self.partial_response_content)
|
||||
max_output_tokens = self.main_model.info.get("max_output_tokens", 0)
|
||||
max_output_tokens = self.main_model.info.get("max_output_tokens") or 0
|
||||
|
||||
input_tokens = self.main_model.token_count(self.format_messages())
|
||||
max_input_tokens = self.main_model.info.get("max_input_tokens", 0)
|
||||
max_input_tokens = self.main_model.info.get("max_input_tokens") or 0
|
||||
|
||||
total_tokens = input_tokens + output_tokens
|
||||
|
||||
|
|
|
@ -344,7 +344,7 @@ class Commands:
|
|||
total_cost = 0.0
|
||||
for tk, msg, tip in res:
|
||||
total += tk
|
||||
cost = tk * self.coder.main_model.info.get("input_cost_per_token", 0)
|
||||
cost = tk * (self.coder.main_model.info.get("input_cost_per_token") or 0)
|
||||
total_cost += cost
|
||||
msg = msg.ljust(col_width)
|
||||
self.io.tool_output(f"${cost:7.4f} {fmt(tk)} {msg} {tip}") # noqa: E231
|
||||
|
@ -352,7 +352,7 @@ class Commands:
|
|||
self.io.tool_output("=" * (width + cost_width + 1))
|
||||
self.io.tool_output(f"${total_cost:7.4f} {fmt(total)} tokens total") # noqa: E231
|
||||
|
||||
limit = self.coder.main_model.info.get("max_input_tokens", 0)
|
||||
limit = self.coder.main_model.info.get("max_input_tokens") or 0
|
||||
if not limit:
|
||||
return
|
||||
|
||||
|
|
|
@ -405,9 +405,7 @@ class Model:
|
|||
self.missing_keys = res.get("missing_keys")
|
||||
self.keys_in_environment = res.get("keys_in_environment")
|
||||
|
||||
max_input_tokens = self.info.get("max_input_tokens")
|
||||
if not max_input_tokens:
|
||||
max_input_tokens = 0
|
||||
max_input_tokens = self.info.get("max_input_tokens") or 0
|
||||
if max_input_tokens < 32 * 1024:
|
||||
self.max_chat_history_tokens = 1024
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue