Fix litellm_proxy model info JSON parsing error handling (#10009)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Xingyao Wang
2025-07-31 10:52:36 -04:00
committed by GitHub
parent 953902dcce
commit 5282770a4c
3 changed files with 27 additions and 24 deletions

View File

@@ -461,12 +461,16 @@ class LLM(RetryMixin, DebugMixin):
},
)
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', [])
try:
resp_json = response.json()
if 'data' not in resp_json:
logger.info(
f'No data field in model info response from LiteLLM proxy: {resp_json}'
)
all_model_info = resp_json.get('data', [])
except Exception as e:
logger.info(f'Error parsing JSON response from LiteLLM proxy: {e}')
all_model_info = []
current_model_info = next(
(
info