Compare commits

...

2 Commits

Author SHA1 Message Date
Jonathan Hill 9ad13f7036
Merge 182bff1bd8 into 3f1a7cc25b 2026-06-09 21:44:26 +08:00
Jonathan Hill 182bff1bd8 fix: guard against empty/filtered LLM responses in chat_api.py
Add null check before accessing choices[0].message.content in the
non-streaming path. An empty choices list causes IndexError; a None
message (returned by some providers on content-filtered responses
with HTTP 200) causes AttributeError.
2026-05-18 03:44:31 -05:00
1 changed files with 2 additions and 0 deletions

View File

@ -21,6 +21,8 @@ while True:
extra_body={"chat_template_kwargs": {"open_thinking": True}, "reasoning_effort": "medium"} # 思考开关
)
if not stream:
if not response.choices or response.choices[0].message is None:
raise ValueError("LLM returned empty or filtered response")
assistant_res = response.choices[0].message.content
print('[A]: ', assistant_res)
else: