File size: 953 Bytes
dd39c08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
Usage
=====

.. _installation:

Installation
------------

To use BrowserGym, first install it using pip:

.. code-block:: console

   pip install browsergym

Then, a required step is to setup playwright by running

.. code-block:: console

   playwright install chromium

Example code
------------

Boilerplate code to run an agent on an interactive, open-ended task:

.. code-block:: python

   import gymnasium as gym
   import browsergym.core  # register the openended task as a gym environment

   env = gym.make(
       "browsergym/openended",
       task_kwargs={"start_url": "https://www.google.com/"},  # starting URL
       wait_for_user_message=True,  # wait for a user message after each agent message sent to the chat
   )

   obs, info = env.reset()
   done = False
   while not done:
       action = ...  # implement your agent here
       obs, reward, terminated, truncated, info = env.step(action)
       done = terminated or truncated