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

Function parse_action

eval_heldout/webarena/browser_env/envs.py:43–64  ·  view source on GitHub ↗
(action: str)

Source from the content-addressed store, hash-verified

41
42@beartype
43def parse_action(action: str) -> PlaywrightScript:
44 splitted = action.strip().split(" ")
45 assert len(splitted) >= 2
46 match splitted[:2]:
47 case ["goto", url]:
48 assert len(splitted) == 2
49 return PlaywrightScript("goto", url)
50 case ["get_by_role", destination]:
51 assert len(splitted) >= 4
52 match splitted[2:]:
53 case [name, operation]:
54 return PlaywrightScript(
55 "get_by_role", destination, name, operation
56 )
57 case [name, operation, value]:
58 return PlaywrightScript(
59 "get_by_role", destination, name, operation, value
60 )
61 case _:
62 raise ValueError("Invalid action")
63 case _:
64 raise ValueError(f"Invalid action {action}")
65
66
67class ScriptBrowserEnv(Env[dict[str, Observation], Action]):

Callers

nothing calls this directly

Calls 1

PlaywrightScriptClass · 0.85

Tested by

no test coverage detected