(
self, trajectory: Trajectory, intent: str, meta_data: dict[str, Any]
)
| 123 | |
| 124 | @beartype |
| 125 | def next_action( |
| 126 | self, trajectory: Trajectory, intent: str, meta_data: dict[str, Any] |
| 127 | ) -> Action: |
| 128 | prompt = self.prompt_constructor.construct( |
| 129 | trajectory, intent, meta_data |
| 130 | ) |
| 131 | lm_config = self.lm_config |
| 132 | n = 0 |
| 133 | while True: |
| 134 | response = call_llm(lm_config, prompt) |
| 135 | force_prefix = self.prompt_constructor.instruction[ |
| 136 | "meta_data" |
| 137 | ].get("force_prefix", "") |
| 138 | response = f"{force_prefix}{response}" |
| 139 | n += 1 |
| 140 | try: |
| 141 | parsed_response = self.prompt_constructor.extract_action( |
| 142 | response |
| 143 | ) |
| 144 | if self.action_set_tag in ["id_html_tree", "id_html_nasc_tree", "id_accessibility_tree"]: |
| 145 | action = create_id_based_action(parsed_response) |
| 146 | elif self.action_set_tag == "playwright": |
| 147 | action = create_playwright_action(parsed_response) |
| 148 | else: |
| 149 | raise ValueError( |
| 150 | f"Unknown action type {self.action_set_tag}" |
| 151 | ) |
| 152 | action["raw_prediction"] = response |
| 153 | break |
| 154 | except ActionParsingError as e: |
| 155 | if n >= lm_config.gen_config["max_retry"]: |
| 156 | action = create_none_action() |
| 157 | action["raw_prediction"] = response |
| 158 | break |
| 159 | |
| 160 | return action |
| 161 | |
| 162 | def check_action( |
| 163 | self, trajectory: Trajectory, intent: str, meta_data: dict[str, Any], target_action: str |
nothing calls this directly
no test coverage detected