fix: Handle missing model info values gracefully

This commit is contained in:
Paul Gauthier 2024-08-07 07:45:39 -03:00 committed by Paul Gauthier (aider)
parent 72572f06d9
commit e48fecee14
3 changed files with 6 additions and 8 deletions

View file

@ -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