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

Function parse_action

webarena/browser_env/envs.py:45–66  ·  view source on GitHub ↗
(action: str)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

PlaywrightScriptClass · 0.85

Tested by

no test coverage detected