mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 09:45:24 -04:00
fix: skip malformed document tool call items (#3494)
This commit is contained in:
+12
-2
@@ -1258,14 +1258,24 @@ def function_call_to_tool_block(name: str, arguments: str) -> Optional[ToolBlock
|
||||
content = "\n".join(parts)
|
||||
elif tool_type == "edit_document":
|
||||
blocks = []
|
||||
for edit in args.get("edits", []):
|
||||
edits = args.get("edits", [])
|
||||
if not isinstance(edits, list):
|
||||
edits = []
|
||||
for edit in edits:
|
||||
if not isinstance(edit, dict):
|
||||
continue
|
||||
blocks.append(
|
||||
f'<<<FIND>>>\n{edit.get("find", "")}\n<<<REPLACE>>>\n{edit.get("replace", "")}\n<<<END>>>'
|
||||
)
|
||||
content = "\n".join(blocks)
|
||||
elif tool_type == "suggest_document":
|
||||
blocks = []
|
||||
for s in args.get("suggestions", []):
|
||||
suggestions = args.get("suggestions", [])
|
||||
if not isinstance(suggestions, list):
|
||||
suggestions = []
|
||||
for s in suggestions:
|
||||
if not isinstance(s, dict):
|
||||
continue
|
||||
blocks.append(
|
||||
f'<<<FIND>>>\n{s.get("find", "")}\n<<<SUGGEST>>>\n{s.get("replace", "")}\n<<<REASON>>>\n{s.get("reason", "")}\n<<<END>>>'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user