mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 01:35:00 +00:00
style: Run linter on aider/models.py
This commit is contained in:
parent
90b5f897f9
commit
9badb711ff
1 changed files with 8 additions and 5 deletions
|
@ -238,7 +238,6 @@ class ModelInfoManager:
|
|||
|
||||
return cached_info
|
||||
|
||||
|
||||
def fetch_openrouter_model_info(self, model):
|
||||
"""
|
||||
Fetch model info by scraping the openrouter model page.
|
||||
|
@ -246,19 +245,23 @@ class ModelInfoManager:
|
|||
Example: openrouter/qwen/qwen-2.5-72b-instruct:free
|
||||
Returns a dict with keys: max_tokens, max_input_tokens, max_output_tokens, input_cost_per_token, output_cost_per_token.
|
||||
"""
|
||||
url_part = model[len("openrouter/"):]
|
||||
url_part = model[len("openrouter/") :]
|
||||
url = "https://openrouter.ai/" + url_part
|
||||
try:
|
||||
import requests
|
||||
|
||||
response = requests.get(url, timeout=5, verify=self.verify_ssl)
|
||||
if response.status_code != 200:
|
||||
return {}
|
||||
html = response.text
|
||||
import re
|
||||
if re.search(rf'The model\s*.*{re.escape(url_part)}.* is not available', html, re.IGNORECASE):
|
||||
|
||||
if re.search(
|
||||
rf"The model\s*.*{re.escape(url_part)}.* is not available", html, re.IGNORECASE
|
||||
):
|
||||
print(f"\033[91mError: Model '{url_part}' is not available\033[0m")
|
||||
return {}
|
||||
text = re.sub(r'<[^>]+>', ' ', html)
|
||||
text = re.sub(r"<[^>]+>", " ", html)
|
||||
context_match = re.search(r"([\d,]+)\s*context", text)
|
||||
if context_match:
|
||||
context_str = context_match.group(1).replace(",", "")
|
||||
|
@ -283,6 +286,7 @@ class ModelInfoManager:
|
|||
print("Error fetching openrouter info:", str(e))
|
||||
return {}
|
||||
|
||||
|
||||
model_info_manager = ModelInfoManager()
|
||||
|
||||
|
||||
|
@ -523,7 +527,6 @@ class Model(ModelSettings):
|
|||
self.use_repo_map = True
|
||||
return # <--
|
||||
|
||||
|
||||
# use the defaults
|
||||
if self.edit_format == "diff":
|
||||
self.use_repo_map = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue