mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-20 03:35:35 -04:00
fix(llm): guard against null arguments in streaming tool-call accumulator (#2923)
This commit is contained in:
+6
-1
@@ -1690,7 +1690,12 @@ async def stream_llm(url: str, model: str, messages: List[Dict], temperature: fl
|
||||
if func.get("name"):
|
||||
_tc_acc[idx]["name"] = func["name"]
|
||||
if "arguments" in func:
|
||||
_tc_acc[idx]["arguments"] += func["arguments"]
|
||||
# Guard against a null arguments delta: `func` can be
|
||||
# {"arguments": None} (JSON null), and a raw `+= None`
|
||||
# raises TypeError that the broad except swallows,
|
||||
# silently dropping the rest of the chunk. Matches the
|
||||
# Anthropic accumulator (`partial = ... or ""`) above.
|
||||
_tc_acc[idx]["arguments"] += func["arguments"] or ""
|
||||
# Stream tool arg deltas for doc tools
|
||||
if func["arguments"] and _tc_acc[idx].get("name") in ("create_document", "update_document", "edit_document"):
|
||||
yield f'data: {json.dumps({"type": "tool_call_delta", "index": idx, "name": _tc_acc[idx]["name"], "arg_delta": func["arguments"]})}\n\n'
|
||||
|
||||
Reference in New Issue
Block a user