From 606fab4cfa346657c6e06f4e99ba2dc622a421bd Mon Sep 17 00:00:00 2001 From: Timothyxxx <384084775@qq.com> Date: Wed, 31 Jan 2024 00:29:51 +0800 Subject: [PATCH] Fix minor bug when get a11y tree and linearize for agent --- mm_agents/gpt_4v_agent.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm_agents/gpt_4v_agent.py b/mm_agents/gpt_4v_agent.py index 507f2c6..0dd15cf 100644 --- a/mm_agents/gpt_4v_agent.py +++ b/mm_agents/gpt_4v_agent.py @@ -45,15 +45,15 @@ def linearize_accessibility_tree(accessibility_tree): linearized_accessibility_tree += node.attrib.get('name') + "\t" if node.text: linearized_accessibility_tree += (node.text if '"' not in node.text else '"{:}"'.format(node.text.replace('"', '""'))) + "\t" - elif node.get("{uri:deskat:uia.windows.microsoft.org}class").endswith("EditWrapper")\ + elif node.get("{uri:deskat:uia.windows.microsoft.org}class", "").endswith("EditWrapper")\ and node.get("{uri:deskat:value.at-spi.gnome.org}value"): text: str = node.get("{uri:deskat:value.at-spi.gnome.org}value") linearized_accessibility_tree += (text if '"' not in text else '"{:}"'.format(text.replace('"', '""'))) + "\t" else: linearized_accessibility_tree += '""\t' linearized_accessibility_tree += node.attrib.get( - '{uri:deskat:component.at-spi.gnome.org}screencoord') + "\t" - linearized_accessibility_tree += node.attrib.get('{uri:deskat:component.at-spi.gnome.org}size') + "\n" + '{uri:deskat:component.at-spi.gnome.org}screencoord', "") + "\t" + linearized_accessibility_tree += node.attrib.get('{uri:deskat:component.at-spi.gnome.org}size', "") + "\n" return linearized_accessibility_tree