Buckets:

download
raw
47.7 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Helium Browser Environment&quot;,&quot;local&quot;:&quot;helium-browser-environment&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;How to run the browser agent&quot;,&quot;local&quot;:&quot;how-to-run-the-browser-agent&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;How browser agents work&quot;,&quot;local&quot;:&quot;how-browser-agents-work&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Tasks&quot;,&quot;local&quot;:&quot;tasks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;The OpenEnv pieces&quot;,&quot;local&quot;:&quot;the-openenv-pieces&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;1. Define the data contract&quot;,&quot;local&quot;:&quot;1-define-the-data-contract&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;2. Implement the environment lifecycle&quot;,&quot;local&quot;:&quot;2-implement-the-environment-lifecycle&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;3. Turn it into a server&quot;,&quot;local&quot;:&quot;3-turn-it-into-a-server&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;4. Add the typed client&quot;,&quot;local&quot;:&quot;4-add-the-typed-client&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;How it fits together&quot;,&quot;local&quot;:&quot;how-it-fits-together&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;The OpenEnv loop&quot;,&quot;local&quot;:&quot;the-openenv-loop&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Notes&quot;,&quot;local&quot;:&quot;notes&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/>
<link href="/docs/openenv/main/en/_app/immutable/entry/start.DlrYIt0I.js" rel="modulepreload">
<link href="/docs/openenv/main/en/_app/immutable/chunks/C3eqzCeB.js" rel="modulepreload">
<link href="/docs/openenv/main/en/_app/immutable/chunks/wvPyzM3A.js" rel="modulepreload">
<link href="/docs/openenv/main/en/_app/immutable/entry/app.D5gTMQJx.js" rel="modulepreload">
<link href="/docs/openenv/main/en/_app/immutable/chunks/T1rQByR4.js" rel="modulepreload">
<link href="/docs/openenv/main/en/_app/immutable/chunks/Cs50_Xpk.js" rel="modulepreload">
<link href="/docs/openenv/main/en/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload">
<link href="/docs/openenv/main/en/_app/immutable/chunks/BeYo49jn.js" rel="modulepreload">
<link href="/docs/openenv/main/en/_app/immutable/nodes/0.dOdx7xQJ.js" rel="modulepreload">
<link href="/docs/openenv/main/en/_app/immutable/nodes/2.DmdnHBKr.js" rel="modulepreload">
<link href="/docs/openenv/main/en/_app/immutable/chunks/B2mxJc_V.js" rel="modulepreload">
<!--16y3a01--><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Helium Browser Environment&quot;,&quot;local&quot;:&quot;helium-browser-environment&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;How to run the browser agent&quot;,&quot;local&quot;:&quot;how-to-run-the-browser-agent&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;How browser agents work&quot;,&quot;local&quot;:&quot;how-browser-agents-work&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Tasks&quot;,&quot;local&quot;:&quot;tasks&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;The OpenEnv pieces&quot;,&quot;local&quot;:&quot;the-openenv-pieces&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;1. Define the data contract&quot;,&quot;local&quot;:&quot;1-define-the-data-contract&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;2. Implement the environment lifecycle&quot;,&quot;local&quot;:&quot;2-implement-the-environment-lifecycle&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;3. Turn it into a server&quot;,&quot;local&quot;:&quot;3-turn-it-into-a-server&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;4. Add the typed client&quot;,&quot;local&quot;:&quot;4-add-the-typed-client&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;How it fits together&quot;,&quot;local&quot;:&quot;how-it-fits-together&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;The OpenEnv loop&quot;,&quot;local&quot;:&quot;the-openenv-loop&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Notes&quot;,&quot;local&quot;:&quot;notes&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/><!---->
<link href="/docs/openenv/main/en/_app/immutable/assets/0.tn0RQdqM.css" rel="modulepreload"> <!--[--><!--[0--><!--[--><!--[0--><!--[--><p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg><!----></button></div> <!--[-1--><!--]--></div><!----> <!--[0--><h1 class="relative group"><a id="helium-browser-environment" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#helium-browser-environment"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>Helium Browser Environment</span></h1><!--]--><!----> <p>This example shows the main pieces of an OpenEnv environment by wrapping a
Chromium browser. A client sends one typed action at a time. The environment
performs it with Helium and Selenium, then returns a typed observation with a
fresh screenshot and the current URL.</p> <p>The browser is useful here because the boundary is easy to see: OpenEnv owns
the <code>reset</code>/<code>step</code> protocol, while the environment owns all browser-specific
behavior. The example does not include an agent, so the OpenEnv parts stay in
focus.</p> <p><img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/helium_demo.png" alt="illustrated"/></p> <!--[1--><h2 class="relative group"><a id="how-to-run-the-browser-agent" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-to-run-the-browser-agent"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>How to run the browser agent</span></h2><!--]--><!----> <p>The actual browser loop is <a href="OpenEnv/envs/helium_browser_env/browser.py">browser.py</a>. You can run it with following steps. First publish the environment. Make sure to authenticate yourself with a write token.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->hf auth login
openenv push envs/helium_browser_env \
--repo-id YOUR_USERNAME/helium-browser-env<!----></pre></div><!----> <p>The agent uses the token saved by <code>hf auth login</code>, or <code>HF_TOKEN</code> if it is set.
Make sure that token can access your inference endpoint. Then deploy the model
and provide your endpoint.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-built_in">export</span> HELIUM_BROWSER_IMAGE=<span class="hljs-string">&#x27;hf.co/spaces/YOUR_USERNAME/helium-browser-env&#x27;</span>
<span class="hljs-built_in">export</span> BASE_URL=<span class="hljs-string">&#x27;https://YOUR_ENDPOINT.endpoints.huggingface.cloud/v1&#x27;</span>
<span class="hljs-built_in">export</span> MODEL_ID=<span class="hljs-string">&quot;HF-MODEL-ID&quot;</span> <span class="hljs-comment"># replace with the model you run endpoint with</span><!----></pre></div><!----> <p>Run browser.py loop inside Hugging Face Sandboxes.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> runpy
<span class="hljs-keyword">from</span> openenv.core.containers.runtime.hf_sandbox_provider <span class="hljs-keyword">import</span> HFSandboxProvider
<span class="hljs-keyword">with</span> HFSandboxProvider(
image=os.environ[<span class="hljs-string">&quot;HELIUM_BROWSER_IMAGE&quot;</span>],
flavor=<span class="hljs-string">&quot;cpu-basic&quot;</span>,
env_vars={<span class="hljs-string">&quot;BROWSER_SANDBOX&quot;</span>: <span class="hljs-string">&quot;hf&quot;</span>},
) <span class="hljs-keyword">as</span> provider:
url = provider.start_container()
provider.wait_for_ready(url, timeout_s=<span class="hljs-number">300</span>)
os.environ[<span class="hljs-string">&quot;BROWSER_BASE_URL&quot;</span>] = url
runpy.run_path(<span class="hljs-string">&quot;envs/helium_browser_env/browser.py&quot;</span>, run_name=<span class="hljs-string">&quot;__main__&quot;</span>)<!----></pre></div><!----> <p>Rest of this tutorial goes through OpenEnv basics and how to build a multimodal browser agent.</p> <!--[1--><h2 class="relative group"><a id="how-browser-agents-work" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-browser-agents-work"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>How browser agents work</span></h2><!--]--><!----> <p>A natively multimodal browser agent operates in a loop:</p> <ol><li><strong>Observe:</strong> receive the current page, as a screenshot.</li> <li><strong>Decide:</strong> choose one small action that moves the task forward.</li> <li><strong>Act:</strong> click, type, press a key, scroll, or navigate.</li> <li><strong>Observe again:</strong> inspect the page after the action instead of assuming it
worked.</li> <li><strong>Stop:</strong> finish when the task is complete or the episode reaches a limit.</li></ol> <p>This example uses screenshots as the main observation. The agent sees the same
800×600 browser image that the environment uses for coordinates, then returns
one structured action. A click such as <code>x=320, y=180</code> means a click position in that
image; it is not a CSS selector or a reference to the page’s HTML.</p> <p>One action per step matters because web pages change. A click may open a menu,
show a cookie banner, navigate to another page, or fail. Returning a fresh
screenshot and URL after every action lets the caller react to what actually
happened. It also produces a clear trajectory: observation, action, next
observation.</p> <p>That loop explains the design choices used later in this example:</p> <ul><li><strong>Typed actions</strong> give OpenEnv a small, validated set of actions for controlling
the browser.</li> <li><strong>A fixed viewport</strong> keeps screenshot pixels and click coordinates aligned.</li> <li><strong>Real pointer events</strong> let clicks reach visual controls such as overlays and
canvases without exposing DOM selectors to the agent.</li> <li><strong>An isolated browser</strong> keeps temporary profiles and untrusted pages away
from the user’s personal browser session.</li> <li><strong>Step limits and <code>done</code></strong> give every browser episode a definite boundary.</li></ul> <p>The agent or policy that chooses actions is intentionally outside this
environment. OpenEnv provides the repeatable interaction contract; the caller
decides how to turn an observation into the next <code>BrowserAction</code>.</p> <!--[1--><h2 class="relative group"><a id="tasks" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tasks"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>Tasks</span></h2><!--]--><!----> <p>Websites always keep on changing so using a regular dataset doesn’t work. You can try the samples <a href="https://huggingface.co/datasets/merve/browser-tasks" rel="nofollow">in this dataset</a> as they are created late 2026. They are divided into three:</p> <ul><li><strong>Information:</strong> getting an information from a website by browsing it.</li> <li><strong>Navigation:</strong> navigating a specific part of the website.</li> <li><strong>Interaction:</strong> clicking, filtering etc.</li></ul> <!--[1--><h2 class="relative group"><a id="the-openenv-pieces" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#the-openenv-pieces"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>The OpenEnv pieces</span></h2><!--]--><!----> <p>An OpenEnv environment has four small parts in this example:</p> <table><thead><tr><th>OpenEnv concept</th><th>Implementation</th><th>Responsibility</th></tr></thead><tbody><tr><td>Data contract</td><td><code>BrowserAction</code>, <code>BrowserObservation</code>, <code>BrowserState</code></td><td>Defines the validated objects that cross the client/server boundary.</td></tr><tr><td>Environment</td><td><code>BrowserEnvironment</code></td><td>Implements the episode lifecycle: <code>reset</code>, <code>step</code>, <code>state</code>, and <code>close</code>.</td></tr><tr><td>Server</td><td><code>create_app(...)</code> in <code>server/app.py</code></td><td>Turns the environment class and data models into an HTTP/WebSocket service.</td></tr><tr><td>Client</td><td><code>BrowserClient</code></td><td>Serializes actions and reconstructs typed observations and step results.</td></tr></tbody></table> <p>These parts separate domain logic from transport. <code>BrowserEnvironment</code> knows
how to drive a browser, but it does not define HTTP routes. <code>BrowserClient</code> knows how to exchange OpenEnv messages, but it does not import Helium or
Selenium.</p> <!--[2--><h3 class="relative group"><a id="1-define-the-data-contract" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#1-define-the-data-contract"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>1. Define the data contract</span></h3><!--]--><!----> <p><code>models.py</code> subclasses OpenEnv’s three base models with the actions an agent can take: “click”, “type”, “key”, “scroll”, “back”, “wait”, “finish”. x and y are clicking coordinates, dy is change in vertical direction (scroll dy pixels), text is text to be typed on e.g. search bars.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">class</span> <span class="hljs-title class_">BrowserAction</span>(<span class="hljs-title class_ inherited__">Action</span>):
op: <span class="hljs-type">Literal</span>[<span class="hljs-string">&quot;click&quot;</span>, <span class="hljs-string">&quot;type&quot;</span>, <span class="hljs-string">&quot;key&quot;</span>, <span class="hljs-string">&quot;scroll&quot;</span>, <span class="hljs-string">&quot;back&quot;</span>, <span class="hljs-string">&quot;wait&quot;</span>, <span class="hljs-string">&quot;finish&quot;</span>]
x: <span class="hljs-built_in">int</span> | <span class="hljs-literal">None</span> = Field(default=<span class="hljs-literal">None</span>, ge=<span class="hljs-number">0</span>, lt=<span class="hljs-number">800</span>)
y: <span class="hljs-built_in">int</span> | <span class="hljs-literal">None</span> = Field(default=<span class="hljs-literal">None</span>, ge=<span class="hljs-number">0</span>, lt=<span class="hljs-number">600</span>)
text: <span class="hljs-built_in">str</span> = Field(default=<span class="hljs-string">&quot;&quot;</span>, max_length=<span class="hljs-number">2000</span>)
dy: <span class="hljs-built_in">int</span> = Field(default=<span class="hljs-number">0</span>, ge=-<span class="hljs-number">1200</span>, le=<span class="hljs-number">1200</span>)
<span class="hljs-keyword">class</span> <span class="hljs-title class_">BrowserObservation</span>(<span class="hljs-title class_ inherited__">Observation</span>):
screenshot: <span class="hljs-built_in">str</span>
url: <span class="hljs-built_in">str</span>
error: <span class="hljs-built_in">str</span> = <span class="hljs-string">&quot;&quot;</span>
<span class="hljs-keyword">class</span> <span class="hljs-title class_">BrowserState</span>(<span class="hljs-title class_ inherited__">State</span>):
<span class="hljs-keyword">pass</span><!----></pre></div><!----> <p>Actions are taken by the agent and observations are the result of the actions in the environment. On the other hand, OpenEnv uses state to report episode
metadata such as the episode ID and step count, without adding those fields to
every browser observation.</p> <table><thead><tr><th>Operation</th><th>Fields</th><th>What it does</th></tr></thead><tbody><tr><td><code>click</code></td><td><code>x</code>, <code>y</code></td><td>Clicks one point in the 800×600 browser viewport.</td></tr><tr><td><code>type</code></td><td><code>text</code></td><td>Types into the currently focused element.</td></tr><tr><td><code>key</code></td><td><code>text</code></td><td>Presses a supported key such as <code>ENTER</code>, <code>TAB</code>, or <code>CTRL+A</code>.</td></tr><tr><td><code>scroll</code></td><td><code>dy</code></td><td>Scrolls down for positive values and up for negative values.</td></tr><tr><td><code>back</code></td><td>none</td><td>Goes back in browser history.</td></tr><tr><td><code>wait</code></td><td>none</td><td>Waits for the page without performing another action.</td></tr><tr><td><code>finish</code></td><td>optional <code>text</code></td><td>Ends the episode.</td></tr></tbody></table> <p>Click coordinates are browser pixels: <code>x</code> is from 0 to 799 and <code>y</code> is from 0
to 599. Scroll values are limited to the range -1200 to 1200.</p> <p>Supported keys are <code>ENTER</code>, <code>TAB</code>, <code>ESCAPE</code>, <code>BACKSPACE</code>, <code>CTRL+A</code>, <code>UP</code>, <code>DOWN</code>, <code>LEFT</code>, and <code>RIGHT</code>.</p> <p>Every observation contains:</p> <ul><li><code>screenshot</code>: the current browser window as a base64-encoded PNG;</li> <li><code>url</code>: the current page URL;</li> <li><code>error</code>: an empty string or a short error code;</li> <li><code>done</code>: whether the episode has ended.</li></ul> <p>The OpenEnv step result carries a reward of <code>0</code> because this example does not
score browser actions.</p> <p>The episode ends when it receives <code>finish</code>, reaches the configured step limit,
encounters a renderer timeout, or detects a supported bot-verification page.
An action error is reported by exception class name so the caller can inspect
the next screenshot and decide what to do.</p> <!--[2--><h3 class="relative group"><a id="2-implement-the-environment-lifecycle" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#2-implement-the-environment-lifecycle"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>2. Implement the environment lifecycle</span></h3><!--]--><!----> <p><code>BrowserEnvironment</code> subclasses OpenEnv’s <code>Environment</code>. Its methods have the
same roles they would have in a game, simulator, or other environment:</p> <ul><li><code>reset(...)</code> starts a new episode and returns its first observation. Here it
creates a temporary browser profile, opens <code>start_url</code>, and takes a
screenshot.</li> <li><code>step(action)</code> applies exactly one validated action and returns the next
observation.</li> <li><code>state</code> exposes the current <code>BrowserState</code>, including OpenEnv’s episode ID
and step count.</li> <li><code>close()</code> releases the resources owned by the episode.</li></ul> <p>This is the Gym-like core of OpenEnv. Browser setup and Helium calls are
ordinary implementation details behind that interface.</p> <!--[2--><h3 class="relative group"><a id="3-turn-it-into-a-server" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#3-turn-it-into-a-server"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>3. Turn it into a server</span></h3><!--]--><!----> <p><code>server/app.py</code> passes the environment class and its wire types to <code>create_app</code>:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-python "><!---->app = create_app(
BrowserEnvironment,
BrowserAction,
BrowserObservation,
env_name=<span class="hljs-string">&quot;helium_browser_env&quot;</span>,
max_concurrent_envs=<span class="hljs-number">1</span>,
)<!----></pre></div><!----> <p><code>create_app</code> supplies the FastAPI application and the standard OpenEnv
endpoints, including health, reset, step, state, and WebSocket access. The
environment code only implements the lifecycle; it does not duplicate those
routes.</p> <p>The environment class is passed instead of a pre-built instance so OpenEnv can
own its lifecycle. Concurrency is limited to one because Helium stores the
active Selenium driver globally and Selenium drivers are not thread-safe.</p> <!--[2--><h3 class="relative group"><a id="4-add-the-typed-client" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#4-add-the-typed-client"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>4. Add the typed client</span></h3><!--]--><!----> <p><code>BrowserClient</code> subclasses OpenEnv’s generic <code>EnvClient</code> with the action,
observation, and state types:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">class</span> <span class="hljs-title class_">BrowserClient</span>(EnvClient[BrowserAction, BrowserObservation, BrowserState]):
<span class="hljs-keyword">def</span> <span class="hljs-title function_">_step_payload</span>(<span class="hljs-params">self, action</span>):
<span class="hljs-keyword">return</span> action.model_dump()
<span class="hljs-keyword">def</span> <span class="hljs-title function_">_parse_result</span>(<span class="hljs-params">self, payload</span>): ...
<span class="hljs-keyword">def</span> <span class="hljs-title function_">_parse_state</span>(<span class="hljs-params">self, payload</span>):
<span class="hljs-keyword">return</span> BrowserState.model_validate(payload)<!----></pre></div><!----> <p>The base client handles the connection and the common <code>reset</code>, <code>step</code>, and
state operations. This subclass only teaches it how this environment’s models
map to JSON. Callers therefore work with <code>BrowserAction</code> and <code>BrowserObservation</code>, not untyped dictionaries.</p> <!--[1--><h2 class="relative group"><a id="how-it-fits-together" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#how-it-fits-together"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>How it fits together</span></h2><!--]--><!----> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-text "><!---->BrowserClient -&gt; OpenEnv server -&gt; BrowserEnvironment -&gt; Helium/Selenium -&gt; Chromium
BrowserClient &lt;- screenshot, URL, error, done &lt;- BrowserEnvironment<!----></pre></div><!----> <p>For a step, <code>BrowserClient</code> serializes a <code>BrowserAction</code>. OpenEnv validates it,
calls <code>BrowserEnvironment.step()</code>, and serializes the returned <code>BrowserObservation</code>. The client then rebuilds a typed <code>StepResult</code> containing
the observation, reward, and <code>done</code> flag.</p> <!--[1--><h2 class="relative group"><a id="the-openenv-loop" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#the-openenv-loop"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>The OpenEnv loop</span></h2><!--]--><!----> <p>Here’s how OpenEnv loop works: once the model server is running, reset the browser to a URL and send one action at a time.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-python "><!----><span class="hljs-keyword">from</span> helium_browser_env.client <span class="hljs-keyword">import</span> BrowserClient
<span class="hljs-keyword">from</span> helium_browser_env.models <span class="hljs-keyword">import</span> BrowserAction
<span class="hljs-keyword">with</span> BrowserClient(base_url=<span class="hljs-string">&quot;http://localhost:8000&quot;</span>).sync() <span class="hljs-keyword">as</span> browser:
result = browser.reset(start_url=<span class="hljs-string">&quot;https://example.com&quot;</span>)
observation = result.observation
result = browser.step(BrowserAction(op=<span class="hljs-string">&quot;scroll&quot;</span>, dy=<span class="hljs-number">500</span>))
observation = result.observation
<span class="hljs-built_in">print</span>(observation.url)
<span class="hljs-built_in">print</span>(observation.error)
<span class="hljs-built_in">print</span>(result.done, result.reward)
<span class="hljs-built_in">print</span>(observation.screenshot) <span class="hljs-comment"># Base64-encoded PNG</span><!----></pre></div><!----> <p>It starts a fresh browser profile, opens the page, and returns the first
observation. <code>step</code> performs one action and returns an OpenEnv <code>StepResult</code>.
The result groups the next observation with the reward and episode termination
flag.</p> <!--[1--><h2 class="relative group"><a id="notes" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#notes"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>Notes</span></h2><!--]--><!----> <p>The environment is designed to run inside its browser sandbox, not against a
personal desktop browser. Chromium uses a temporary profile for each episode.
Downloads and password storage are disabled, and a reset rejects URLs that
contain a username or password.</p> <p>Web pages are untrusted input. Do not enter credentials or sensitive data, and
expect some sites to show automation challenges. This example provides the
browser interaction loop; it does not provide tasks, scoring, or a reward
function.</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/openenv/blob/main/docs/source/environments/helium_browser.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg><!----> <span><span class="underline">Update</span> on GitHub</span></a><!----> <p></p><!--]--><!----><!--]--><!--]--><!--]--> <!--[-1--><!--]--><!--]-->
<script>
{
__sveltekit_wu2865 = {
base: "/docs/openenv/main/en",
assets: "/docs/openenv/main/en"
};
const element = document.currentScript.parentElement;
Promise.all([
import("/docs/openenv/main/en/_app/immutable/entry/start.DlrYIt0I.js"),
import("/docs/openenv/main/en/_app/immutable/entry/app.D5gTMQJx.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 2],
data: [null,null],
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
47.7 kB
·
Xet hash:
848345248d84d966cc9de2bfa2c9c201f98c3786f7bf33f32d6e1d163832a327

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.