API: Fix tool call parser crash on non-dict JSON output

This commit is contained in:
oobabooga 2026-04-03 16:56:15 -07:00
parent 8ecdb41078
commit fc35acab9b

View file

@ -699,6 +699,8 @@ def parse_tool_call(answer: str, tool_names: list[str], return_prefix: bool = Fa
if not isinstance(candidates, list):
candidates = [candidates]
for candidate_dict in candidates:
if not isinstance(candidate_dict, dict):
continue
checked_candidate = check_and_sanitize_tool_call_candidate(candidate_dict, tool_names)
if checked_candidate is not None:
matches.append(checked_candidate)