Skip to content

Commit

Permalink
Fix Openrouter (#4641)
Browse files Browse the repository at this point in the history
  • Loading branch information
enyst authored Oct 30, 2024
1 parent 2587220 commit bde978c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions openhands/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ def __init__(
# 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(
Expand Down

0 comments on commit bde978c

Please sign in to comment.