MCPcopy Create free account
hub / github.com/THUDM/AutoWebGLM / check_action

Method check_action

webarena/agent/agent.py:162–199  ·  view source on GitHub ↗
(
        self, trajectory: Trajectory, intent: str, meta_data: dict[str, Any], target_action: str
    )

Source from the content-addressed store, hash-verified

160 return action
161
162 def check_action(
163 self, trajectory: Trajectory, intent: str, meta_data: dict[str, Any], target_action: str
164 ) -> Action:
165 prompt = self.prompt_constructor.construct(
166 trajectory, intent, meta_data
167 )
168 lm_config = self.lm_config
169 n = 0
170
171 # agent will retry if the action is not parsed correctly
172 while True:
173 response = target_action
174 force_prefix = self.prompt_constructor.instruction[
175 "meta_data"
176 ].get("force_prefix", "")
177 response = f"{force_prefix}{response}"
178 n += 1
179 try:
180 parsed_response = self.prompt_constructor.extract_action(
181 response
182 )
183 if self.action_set_tag in ["id_accessibility_tree", "id_html_tree", "id_html_nasc_tree"]:
184 action = create_id_based_action(parsed_response)
185 elif self.action_set_tag == "playwright":
186 action = create_playwright_action(parsed_response)
187 else:
188 raise ValueError(
189 f"Unknown action type {self.action_set_tag}"
190 )
191 action["raw_prediction"] = response
192 break
193 except ActionParsingError as e:
194 if n >= lm_config.gen_config["max_retry"]:
195 action = create_none_action()
196 action["raw_prediction"] = response
197 break
198
199 return prompt, action
200
201 def reset(self, test_config_file: str) -> None:
202 pass

Callers

nothing calls this directly

Calls 5

create_id_based_actionFunction · 0.90
create_playwright_actionFunction · 0.90
create_none_actionFunction · 0.90
extract_actionMethod · 0.80
constructMethod · 0.45

Tested by

no test coverage detected