-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy path__init__.py
More file actions
160 lines (141 loc) · 6.09 KB
/
__init__.py
File metadata and controls
160 lines (141 loc) · 6.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
__version__ = "0.4.1"
import inspect
from logging import warning
import numpy as np
from browsergym.core.registration import register_task
from .tasks.comp_building_block import CompositionalBuildingBlockTask
from .tasks.compositional import (
AGENT_CURRICULUM_L2,
AGENT_CURRICULUM_L3,
ALL_COMPOSITIONAL_TASKS,
ALL_COMPOSITIONAL_TASKS_L2,
ALL_COMPOSITIONAL_TASKS_L3,
HUMAN_CURRICULUM_L2,
HUMAN_CURRICULUM_L3,
)
from .tasks.compositional.base import CompositionalTask, HumanEvalTask
from .tasks.compositional.update_task import __TASKS__ as UPDATE_TASKS
from .tasks.dashboard import __TASKS__ as DASHBOARD_TASKS
from .tasks.form import __TASKS__ as FORM_TASKS
from .tasks.knowledge import __TASKS__ as KB_TASKS
from .tasks.list import __TASKS__ as LIST_TASKS
from .tasks.navigation import __TASKS__ as NAVIGATION_TASKS
from .tasks.service_catalog import __TASKS__ as SERVICE_CATALOG_TASKS
ALL_WORKARENA_TASKS = [
*ALL_COMPOSITIONAL_TASKS_L2,
*ALL_COMPOSITIONAL_TASKS_L3,
*DASHBOARD_TASKS,
*FORM_TASKS,
*KB_TASKS,
*LIST_TASKS,
*NAVIGATION_TASKS,
*SERVICE_CATALOG_TASKS,
*UPDATE_TASKS,
]
ATOMIC_TASKS = [
task
for task in ALL_WORKARENA_TASKS
if inspect.isclass(task)
and not issubclass(task, CompositionalTask)
and not issubclass(task, CompositionalBuildingBlockTask)
]
# register the WorkArena benchmark
for task in ALL_WORKARENA_TASKS:
register_task(
task.get_task_id(),
task,
)
workarena_tasks_all = [task_class.get_task_id() for task_class in ALL_WORKARENA_TASKS]
workarena_tasks_atomic = [task_class.get_task_id() for task_class in ATOMIC_TASKS]
TASK_CATEGORY_MAP = {
"workarena.servicenow.all-menu": "menu",
"workarena.servicenow.create-change-request": "form",
"workarena.servicenow.create-hardware-asset": "form",
"workarena.servicenow.create-incident": "form",
"workarena.servicenow.create-problem": "form",
"workarena.servicenow.create-user": "form",
"workarena.servicenow.filter-asset-list": "list-filter",
"workarena.servicenow.filter-change-request-list": "list-filter",
"workarena.servicenow.filter-hardware-list": "list-filter",
"workarena.servicenow.filter-incident-list": "list-filter",
"workarena.servicenow.filter-service-catalog-item-list": "list-filter",
"workarena.servicenow.filter-user-list": "list-filter",
"workarena.servicenow.impersonation": "menu",
"workarena.servicenow.knowledge-base-search": "knowledge",
"workarena.servicenow.order-apple-mac-book-pro15": "service catalog",
"workarena.servicenow.order-apple-watch": "service catalog",
"workarena.servicenow.order-developer-laptop": "service catalog",
"workarena.servicenow.order-development-laptop-p-c": "service catalog",
"workarena.servicenow.order-ipad-mini": "service catalog",
"workarena.servicenow.order-ipad-pro": "service catalog",
"workarena.servicenow.order-loaner-laptop": "service catalog",
"workarena.servicenow.order-sales-laptop": "service catalog",
"workarena.servicenow.order-standard-laptop": "service catalog",
"workarena.servicenow.sort-asset-list": "list-sort",
"workarena.servicenow.sort-change-request-list": "list-sort",
"workarena.servicenow.sort-hardware-list": "list-sort",
"workarena.servicenow.sort-incident-list": "list-sort",
"workarena.servicenow.sort-service-catalog-item-list": "list-sort",
"workarena.servicenow.sort-user-list": "list-sort",
"workarena.servicenow.multi-chart-min-max-retrieval": "dashboard",
"workarena.servicenow.multi-chart-value-retrieval": "dashboard",
"workarena.servicenow.single-chart-value-retrieval": "dashboard",
"workarena.servicenow.single-chart-min-max-retrieval": "dashboard",
}
workarena_tasks_l1 = list(TASK_CATEGORY_MAP.keys())
workarena_task_categories = {}
for task in workarena_tasks_atomic:
if task not in TASK_CATEGORY_MAP:
warning(f"Atomic task {task} not found in TASK_CATEGORY_MAP")
continue
cat = TASK_CATEGORY_MAP[task]
if cat in workarena_task_categories:
workarena_task_categories[cat].append(task)
else:
workarena_task_categories[cat] = [task]
def get_task_category(task_name):
benchmark = task_name.split(".")[0]
return benchmark, TASK_CATEGORY_MAP.get(task_name, None)
def get_all_tasks_agents(filter="l2", meta_seed=42, n_seed_l1=10, is_agent_curriculum=True):
OFFSET = 42
all_task_tuples = []
filter = filter.split(".")
if len(filter) > 2:
raise Exception("Unsupported filter used.")
if len(filter) == 1:
level = filter[0]
if level not in ["l1", "l2", "l3"]:
raise Exception("Unsupported category of tasks.")
else:
rng = np.random.RandomState(meta_seed)
if level == "l1":
for task in ATOMIC_TASKS:
for seed in rng.randint(0, 1000, n_seed_l1):
all_task_tuples.append((task, int(seed)))
return all_task_tuples
if len(filter) == 2:
level, filter_category = filter[0], filter[1]
if filter_category not in list(AGENT_CURRICULUM_L2.keys()):
raise Exception("Unsupported category of tasks.")
else:
filter_category = None
if is_agent_curriculum:
if level == "l2":
ALL_COMPOSITIONAL_TASKS_CATEGORIES = AGENT_CURRICULUM_L2
else:
ALL_COMPOSITIONAL_TASKS_CATEGORIES = AGENT_CURRICULUM_L3
else:
if level == "l2":
ALL_COMPOSITIONAL_TASKS_CATEGORIES = HUMAN_CURRICULUM_L2
else:
ALL_COMPOSITIONAL_TASKS_CATEGORIES = HUMAN_CURRICULUM_L3
for category, items in ALL_COMPOSITIONAL_TASKS_CATEGORIES.items():
if filter_category and category != filter_category:
continue
for curr_seed in rng.randint(0, 1000, items["num_seeds"]):
random_gen = np.random.RandomState(curr_seed)
for task_set, count in zip(items["buckets"], items["weights"]):
tasks = random_gen.choice(task_set, count, replace=False)
for task in tasks:
all_task_tuples.append((task, int(curr_seed)))
return all_task_tuples