fix: Parse tool call arguments as JSON for improved handling in process method

This commit is contained in:
Showdown76 2025-05-19 13:41:25 +02:00
parent b583094e20
commit 158529a2bd

View File

@ -58,6 +58,7 @@ class AIProcessor:
tool_calls = getattr(response.choices[0].message, "tool_calls", None) tool_calls = getattr(response.choices[0].message, "tool_calls", None)
if tool_calls: if tool_calls:
for tc in tool_calls: for tc in tool_calls:
ags = json.loads(tc.function.arguments)
logger.debug( logger.debug(
"Processing tool call: %s with arguments: %s", "Processing tool call: %s with arguments: %s",
tc.function.name, tc.function.name,
@ -66,15 +67,15 @@ class AIProcessor:
if tc.function.name == "confirm": if tc.function.name == "confirm":
reexec = False reexec = False
try: try:
nextsteps = tc.function.arguments.get("goal", "") nextsteps = ags.get("goal", "")
except: except:
nextsteps = str(tc.function.arguments) nextsteps = str(tc.function.arguments)
print('ERROR NEXT STEPS IS STR, ', nextsteps) print('ERROR NEXT STEPS IS STR, ', nextsteps)
if tc.function.name == "click_button": if tc.function.name == "click_button":
# extract click position for screenshot crosshair # extract click position for screenshot crosshair
click_positions.extend(tuple( # button_type, x, y click_positions.extend(tuple( # button_type, x, y
map(int,(tc.function.arguments.get("x", 0), map(int,(ags.get("x", 0),
tc.function.arguments.get("y", 0) ags.get("y", 0)
) )
) )
)) ))