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

Method next_action

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

call_llmFunction · 0.90
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