mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-04 19:55:00 +00:00
fix: Fix OpenRouter token cost calculation
This commit is contained in:
parent
a7afbd0708
commit
05c56fe904
1 changed files with 2 additions and 2 deletions
|
@ -17,11 +17,11 @@ import requests
|
||||||
|
|
||||||
|
|
||||||
def _cost_per_token(val: str | None) -> float | None:
|
def _cost_per_token(val: str | None) -> float | None:
|
||||||
"""Convert a per-million price string to a per-token float."""
|
"""Convert a price string (USD per token) to a float."""
|
||||||
if val in (None, "", "0"):
|
if val in (None, "", "0"):
|
||||||
return 0.0 if val == "0" else None
|
return 0.0 if val == "0" else None
|
||||||
try:
|
try:
|
||||||
return float(val) / 1_000_000
|
return float(val)
|
||||||
except Exception: # noqa: BLE001
|
except Exception: # noqa: BLE001
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue