Skip to content

πŸ™Œ OpenHands: AI-Driven Development

safer model info access (#4619)

Robert Brennan572b3ad68273
diff --git a/openhands/llm/llm.py b/openhands/llm/llm.py
index 9607e51417..66d3403748 100644
--- a/openhands/llm/llm.py
+++ b/openhands/llm/llm.py
@@ -92,7 +92,12 @@ class LLM(RetryMixin, DebugMixin):
f'{self.config.base_url}/v1/model/info',
headers={'Authorization': f'Bearer {self.config.api_key}'},
)
- all_model_info = response.json()['data']
+ resp_json = response.json()
+ if 'data' not in resp_json:
+ logger.error(
+ f'Error getting model info from LiteLLM proxy: {resp_json}'
+ )
+ all_model_info = resp_json.get('data', [])
current_model_info = next(
(
info