refactor: Add SSL verification control to ModelInfoManager

This commit is contained in:
Paul Gauthier (aider) 2025-03-05 18:34:48 -08:00
parent c7b4c22b94
commit 5f147242be
2 changed files with 8 additions and 2 deletions

View file

@ -510,6 +510,8 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
litellm._load_litellm() litellm._load_litellm()
litellm._lazy_module.client_session = httpx.Client(verify=False) litellm._lazy_module.client_session = httpx.Client(verify=False)
litellm._lazy_module.aclient_session = httpx.AsyncClient(verify=False) litellm._lazy_module.aclient_session = httpx.AsyncClient(verify=False)
# Set verify_ssl on the model_info_manager
models.model_info_manager.set_verify_ssl(False)
if args.timeout: if args.timeout:
models.request_timeout = args.timeout models.request_timeout = args.timeout

View file

@ -138,7 +138,11 @@ class ModelInfoManager:
self.cache_file = self.cache_dir / "model_prices_and_context_window.json" self.cache_file = self.cache_dir / "model_prices_and_context_window.json"
self.content = None self.content = None
self.local_model_metadata = {} self.local_model_metadata = {}
self.verify_ssl = True
self._load_cache() self._load_cache()
def set_verify_ssl(self, verify_ssl):
self.verify_ssl = verify_ssl
def _load_cache(self): def _load_cache(self):
try: try:
@ -154,8 +158,8 @@ class ModelInfoManager:
try: try:
import requests import requests
# this needs to respect the --no-verify-ssl switch. ai! # Respect the --no-verify-ssl switch
response = requests.get(self.MODEL_INFO_URL, timeout=5) response = requests.get(self.MODEL_INFO_URL, timeout=5, verify=self.verify_ssl)
if response.status_code == 200: if response.status_code == 200:
self.content = response.json() self.content = response.json()
try: try: