fix: Allow arbitrary characters in model availability check regex

This commit is contained in:
Stefan Hladnik (aider) 2025-03-18 03:53:27 +07:00 committed by Stefan Hladnik
parent d64427d726
commit 21cca34392

View file

@ -246,10 +246,10 @@ class ModelInfoManager:
if response.status_code != 200:
return {}
html = response.text
if f'The model "{url_part}" is not available' in html:
import re
if re.search(rf'The model\s*.*{re.escape(url_part)}.* is not available', html, re.IGNORECASE):
print(f"Error: Model '{url_part}' is not available")
sys.exit(1)
import re
text = re.sub(r'<[^>]+>', ' ', html)
context_match = re.search(r"([\d,]+)\s*context", text)
if context_match: