Skip to content

Commit

Permalink
code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jardinetsouffleton committed Sep 23, 2024
1 parent 2fb616b commit 9afa49e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/browsergym/workarena/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ def get_all_tasks_agents(filter="l2", meta_seed=42, n_seed_l1=10, is_agent_curri
for task in tasks:
all_task_tuples.append((task, int(curr_seed)))

return all_task_tuples
return all_task_tuples
2 changes: 1 addition & 1 deletion src/browsergym/workarena/tasks/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,4 +801,4 @@ def setup_goal(self, page: playwright.sync_api.Page) -> Tuple[str | dict]:
and issubclass(var, DashboardRetrievalTask)
and not issubclass(var, CompositionalBuildingBlockTask)
and var is not DashboardRetrievalTask
]
]
2 changes: 1 addition & 1 deletion tests/test_compositional.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ def test_cheat_compositional_sampled_human_set_l3(task_entrypoint, seed, page: P

task.teardown()

assert done is True and reward == 1.0
assert done is True and reward == 1.0
24 changes: 13 additions & 11 deletions workarena_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,38 @@

from browsergym.core.env import BrowserEnv
from browsergym.workarena import get_all_tasks_agents

AGENT_L2_SAMPLED_SET = get_all_tasks_agents(filter="l2")

AGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS = [sampled_set[0] for sampled_set in AGENT_L2_SAMPLED_SET], [
sampled_set[1] for sampled_set in AGENT_L2_SAMPLED_SET
]
from time import sleep

for (task, seed) in zip(AGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS):
for task, seed in zip(AGENT_L2_SAMPLED_TASKS, AGENT_L2_SEEDS):
print("Task:", task)

# Instantiate a new environment
env = BrowserEnv(task_entrypoint=task,
headless=False,
slow_mo=1000)
env = BrowserEnv(task_entrypoint=task, headless=False, slow_mo=1000)
env.reset()

# Cheat functions use Playwright to automatically solve the task
env.chat.add_message(role="assistant", msg="On it. Please wait...")

for i in range(len(env.task)):
sleep(1)
env.task.cheat(page=env.page, chat_messages=env.chat.messages, subtask_idx=i)
sleep(1)
reward, done, message, info = env.task.validate(page=env.page, chat_messages=env.chat.messages)

reward, done, message, info = env.task.validate(
page=env.page, chat_messages=env.chat.messages
)

if reward == 1:
env.chat.add_message(role="user", msg="Yes, that works. Thanks!")
else:
env.chat.add_message(role="user", msg=f"No, that doesn't work. {message.get('message', '')}")
env.chat.add_message(
role="user", msg=f"No, that doesn't work. {message.get('message', '')}"
)

sleep(3)
env.close()
env.close()

0 comments on commit 9afa49e

Please sign in to comment.