Fix Openrouter (#4641)

This commit is contained in:
Engel Nyst 2024-10-30 19:31:24 +01:00 committed by GitHub
parent 2587220b12
commit bde978cf0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -91,9 +91,13 @@ class LLM(RetryMixin, DebugMixin):
# litellm actually uses base Exception here for unknown model
self.model_info: ModelInfo | None = None
if self.config.model.startswith('openrouter'):
self.model_info = litellm.get_model_info(self.config.model)
elif self.config.model.startswith('litellm_proxy/'):
try:
if self.config.model.startswith('openrouter'):
self.model_info = litellm.get_model_info(self.config.model)
except Exception as e:
logger.debug(f'Error getting model info: {e}')
if self.config.model.startswith('litellm_proxy/'):
# IF we are using LiteLLM proxy, get model info from LiteLLM proxy
# GET {base_url}/v1/model/info with litellm_model_id as path param
response = requests.get(