Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

More eval examples

Magnus Müllerde57b4f55ce4
diff --git a/eval/gpt-4o-viewport-0.py b/eval/gpt-4o-viewport-0.py
new file mode 100644
index 000000000..eb3ada91b
--- /dev/null
+++ b/eval/gpt-4o-viewport-0.py
@@ -0,0 +1,33 @@
+import asyncio
+
+from dotenv import load_dotenv
+from langchain_openai import ChatOpenAI
+
+from browser_use import Agent, BrowserConfig
+from browser_use.browser.browser import Browser
+from browser_use.browser.context import BrowserContextConfig
+
+load_dotenv()
+
+
+async def run_agent(task: str, max_steps: int = 38):
+ llm = ChatOpenAI(
+ model='gpt-4o',
+ temperature=0.0,
+ )
+ browser = Browser(
+ config=BrowserConfig(
+ new_context_config=BrowserContextConfig(
+ viewport_expansion=0,
+ ),
+ ),
+ )
+ agent = Agent(task=task, llm=llm, browser=browser)
+ result = await agent.run(max_steps=max_steps)
+ return result
+
+
+if __name__ == '__main__':
+ task = 'Go to https://www.google.com and search for "python" and click on the first result'
+ result = asyncio.run(run_agent(task))
+ print(result)
diff --git a/eval/gpt-4o.py b/eval/gpt-4o.py
index b43951d53..3cdcbd64d 100644
--- a/eval/gpt-4o.py
+++ b/eval/gpt-4o.py
@@ -1,3 +1,5 @@
+import asyncio
+
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
@@ -14,3 +16,9 @@ async def run_agent(task: str, max_steps: int = 38):
agent = Agent(task=task, llm=llm)
result = await agent.run(max_steps=max_steps)
return result
+
+
+if __name__ == '__main__':
+ task = 'Go to https://www.google.com and search for "python" and click on the first result'
+ result = asyncio.run(run_agent(task))
+ print(result)