mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 03:05: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
|
return cached_info
|
||||||
|
|
||||||
|
|
||||||
def fetch_openrouter_model_info(self, model):
|
def fetch_openrouter_model_info(self, model):
|
||||||
"""
|
"""
|
||||||
Fetch model info by scraping the openrouter model page.
|
Fetch model info by scraping the openrouter model page.
|
||||||
|
@ -250,15 +249,19 @@ class ModelInfoManager:
|
||||||
url = "https://openrouter.ai/" + url_part
|
url = "https://openrouter.ai/" + url_part
|
||||||
try:
|
try:
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
response = requests.get(url, timeout=5, verify=self.verify_ssl)
|
response = requests.get(url, timeout=5, verify=self.verify_ssl)
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
return {}
|
return {}
|
||||||
html = response.text
|
html = response.text
|
||||||
import re
|
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")
|
print(f"\033[91mError: Model '{url_part}' is not available\033[0m")
|
||||||
return {}
|
return {}
|
||||||
text = re.sub(r'<[^>]+>', ' ', html)
|
text = re.sub(r"<[^>]+>", " ", html)
|
||||||
context_match = re.search(r"([\d,]+)\s*context", text)
|
context_match = re.search(r"([\d,]+)\s*context", text)
|
||||||
if context_match:
|
if context_match:
|
||||||
context_str = context_match.group(1).replace(",", "")
|
context_str = context_match.group(1).replace(",", "")
|
||||||
|
@ -283,6 +286,7 @@ class ModelInfoManager:
|
||||||
print("Error fetching openrouter info:", str(e))
|
print("Error fetching openrouter info:", str(e))
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
model_info_manager = ModelInfoManager()
|
model_info_manager = ModelInfoManager()
|
||||||
|
|
||||||
|
|
||||||
|
@ -523,7 +527,6 @@ class Model(ModelSettings):
|
||||||
self.use_repo_map = True
|
self.use_repo_map = True
|
||||||
return # <--
|
return # <--
|
||||||
|
|
||||||
|
|
||||||
# use the defaults
|
# use the defaults
|
||||||
if self.edit_format == "diff":
|
if self.edit_format == "diff":
|
||||||
self.use_repo_map = True
|
self.use_repo_map = True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue