Skip to content

Commit faeea9f

Browse files
committed
add a check for whether there are any choices in litellm response
1 parent e382ec0 commit faeea9f

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/agents/extensions/models/litellm_model.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,19 @@ async def get_response(
104104
prompt=prompt,
105105
)
106106

107-
assert isinstance(response.choices[0], litellm.types.utils.Choices)
108-
109-
if _debug.DONT_LOG_MODEL_DATA:
110-
logger.debug("Received model response")
111-
else:
112-
logger.debug(
113-
f"""LLM resp:\n{
114-
json.dumps(
115-
response.choices[0].message.model_dump(), indent=2, ensure_ascii=False
116-
)
117-
}\n"""
118-
)
107+
if len(response.choices):
108+
assert isinstance(response.choices[0], litellm.types.utils.Choices)
109+
110+
if _debug.DONT_LOG_MODEL_DATA:
111+
logger.debug("Received model response")
112+
else:
113+
logger.debug(
114+
f"""LLM resp:\n{
115+
json.dumps(
116+
response.choices[0].message.model_dump(), indent=2, ensure_ascii=False
117+
)
118+
}\n"""
119+
)
119120

120121
if hasattr(response, "usage"):
121122
response_usage = response.usage

0 commit comments

Comments
 (0)