Handle LLM returning element_id instead of id, and handle cases where it may not be returned at all (#301)

This commit is contained in:
Kerem Yilmaz
2024-05-12 20:18:34 -07:00
committed by GitHub
parent ab88f24df6
commit 6a83f367ba

View File

@@ -138,7 +138,13 @@ class CompleteAction(DecisiveAction):
def parse_actions(task: Task, json_response: List[Dict[str, Any]]) -> List[Action]:
actions = []
for action in json_response:
element_id = action["id"]
if "id" in action:
element_id = action["id"]
elif "element_id" in action:
element_id = action["element_id"]
else:
element_id = None
reasoning = action["reasoning"] if "reasoning" in action else None
if "action_type" not in action or action["action_type"] is None:
actions.append(NullAction(reasoning=reasoning))