Skip to content

Commit 45c8834

Browse files
committed
rc6
1 parent 4976744 commit 45c8834

File tree

8 files changed

+34
-16
lines changed

8 files changed

+34
-16
lines changed

core/src/browsergym/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.0rc5"
1+
__version__ = "0.1.0rc6"
22

33
import playwright.sync_api
44

core/src/browsergym/core/env.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def step(self, action: str) -> tuple:
262262
self._wait_for_user_message()
263263

264264
# extract reward, done, user_message, info (task-specific)
265-
reward, done, user_message, info = self.task.validate(self.page, self.chat.messages)
265+
reward, done, user_message, info = self._task_validate()
266266

267267
# add any user message sent by the task to the chat
268268
if user_message:
@@ -277,6 +277,24 @@ def step(self, action: str) -> tuple:
277277

278278
return obs, reward, terminated, truncated, info
279279

280+
def _task_validate(self):
281+
# back-up these in case validate() navigates pages and messes the history
282+
prev_active_page = self.page
283+
prev_page_history = self.page_history.copy()
284+
285+
# call validate
286+
reward, done, user_message, info = self.task.validate(self.page, self.chat.messages)
287+
288+
# safety fix, in case validate() did mess up the active page and/or page history
289+
if prev_active_page != self.page or prev_page_history != self.page_history:
290+
logging.warning(
291+
"The active page and / or page history has changed during task.validate(). A recovery fix will be applied."
292+
)
293+
self.page = prev_active_page
294+
self.page_history = prev_page_history
295+
296+
return reward, done, user_message, info
297+
280298
def _wait_for_user_message(self):
281299
# if last message is from the assistant, wait for a user message to continue
282300
# TODO: be smarter about when to wait for a user message (different action from the assistant?)

miniwob/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
browsergym-core==0.1.0rc5
1+
browsergym-core==0.1.0rc6

miniwob/src/browsergym/miniwob/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.0rc5"
1+
__version__ = "0.1.0rc6"
22

33
from browsergym.core.registration import register_task
44

miniwob/src/browsergym/miniwob/all.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,16 +620,16 @@ def setup(self, seed: int, page: playwright.sync_api.Page) -> tuple[str, dict]:
620620

621621
# this task requires specific treatment to recover the text goal
622622
page.evaluate(
623-
f"""\
624-
core.{get_utterance_func} = function () {{
625-
const rgb2hex = (rgb) => `#${{rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/).slice(1).map(n => parseInt(n, 10).toString(16).padStart(2, '0')).join('')}}`
623+
f"core.{get_utterance_func} = function () "
624+
+ r"""{
625+
const rgb2hex = (rgb) => `#${rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/).slice(1).map(n => parseInt(n, 10).toString(16).padStart(2, '0')).join('')}`;
626626
query_div = document.getElementById('query');
627627
utterance = '';
628628
utterance = utterance + query_div.children[0].textContent.replace(/\s+/g, ' ').trim();
629629
utterance = utterance + ' ' + rgb2hex(query_div.children[1].style.backgroundColor);
630630
utterance = utterance + ' ' + query_div.children[2].textContent.replace(/\s+/g, ' ').trim();
631631
return utterance;
632-
}};
632+
};
633633
'';
634634
"""
635635
)

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ classifiers = [
2525
"Topic :: Scientific/Engineering :: Artificial Intelligence",
2626
"License :: OSI Approved :: Apache Software License",
2727
]
28-
version="0.1.0rc5"
28+
version="0.1.0rc6"
2929
dependencies = [
30-
"browsergym-core==0.1.0rc5",
31-
"browsergym-miniwob==0.1.0rc5",
32-
"browsergym-webarena==0.1.0rc5",
33-
"browsergym-workarena==0.1.0rc5",
30+
"browsergym-core==0.1.0rc6",
31+
"browsergym-miniwob==0.1.0rc6",
32+
"browsergym-webarena==0.1.0rc6",
33+
"browsergym-workarena==0.1.0rc6",
3434
]
3535

3636
[tool.setuptools]

webarena/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
browsergym-core==0.1.0rc5
1+
browsergym-core==0.1.0rc6
22
libwebarena==0.0.2

webarena/src/browsergym/webarena/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.0rc5"
1+
__version__ = "0.1.0rc6"
22

33
from browsergym.core.registration import register_task
44

@@ -14,6 +14,6 @@
1414
register_task(
1515
gym_id,
1616
GenericWebArenaTask,
17-
kwargs={"task_id": task_id, "viewport": {"width": 1280, "height": 720}},
17+
kwargs={"task_id": task_id, "viewport": {"width": 1280, "height": 720}, "timeout": 10000},
1818
)
1919
ALL_WEBARENA_TASK_IDS.append(gym_id)

0 commit comments

Comments
 (0)