(
self, trajectory: Trajectory, intent: str, meta_data: dict[str, Any], target_action: str
)
| 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 |
nothing calls this directly
no test coverage detected