MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / test

Function test

eval_heldout/webarena/run.py:207–355  ·  view source on GitHub ↗
(
    args: argparse.Namespace,
    agent: Agent | PromptAgent | TeacherForcingAgent,
    config_file_list: list[str],
)

Source from the content-addressed store, hash-verified

205
206@beartype
207def test(
208 args: argparse.Namespace,
209 agent: Agent | PromptAgent | TeacherForcingAgent,
210 config_file_list: list[str],
211) -> None:
212 scores = []
213 max_steps = args.max_steps
214
215 early_stop_thresholds = {
216 "parsing_failure": args.parsing_failure_th,
217 "repeating_action": args.repeating_action_failure_th,
218 }
219
220 env = ScriptBrowserEnv(
221 headless=not args.render,
222 slow_mo=args.slow_mo,
223 observation_type=args.observation_type,
224 current_viewport_only=args.current_viewport_only,
225 viewport_size={
226 "width": args.viewport_width,
227 "height": args.viewport_height,
228 },
229 save_trace_enabled=args.save_trace_enabled,
230 sleep_after_execution=args.sleep_after_execution,
231 )
232
233 for config_file in config_file_list:
234 idx = Path(config_file).with_suffix('').name
235 interactions = []
236 try:
237 render_helper = RenderHelper(
238 config_file, args.result_dir, args.action_set_tag
239 )
240
241 # get intent
242 with open(config_file) as f:
243 _c = json.load(f)
244 intent = _c["intent"]
245 task_id = _c["task_id"]
246
247 logger.info(f"[Config file]: {config_file}")
248 logger.info(f"[Intent]: {intent}")
249
250 agent.reset(config_file)
251 trajectory: Trajectory = []
252 obs, info = env.reset(options={"config_file": config_file})
253 state_info: StateInfo = {"observation": obs, "info": info}
254 trajectory.append(state_info)
255
256 meta_data = {"action_history": ["None"]}
257 while True:
258 early_stop_flag, stop_info = early_stop(
259 trajectory, max_steps, early_stop_thresholds
260 )
261
262 if early_stop_flag:
263 action = create_stop_action(f"Early stop: {stop_info}")
264 else:

Callers 1

run.pyFile · 0.85

Calls 15

resetMethod · 0.95
renderMethod · 0.95
stepMethod · 0.95
get_page_clientMethod · 0.95
save_traceMethod · 0.95
closeMethod · 0.95
closeMethod · 0.95
ScriptBrowserEnvClass · 0.90
RenderHelperClass · 0.90
create_stop_actionFunction · 0.90
get_action_descriptionFunction · 0.90
evaluator_routerFunction · 0.90

Tested by

no test coverage detected