Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
improve the example
mertunsall85e0bddb6a41
diff --git a/examples/features/judge_trace.py b/examples/features/judge_trace.pyindex 48a5d9d2e..9baec44a0 100644--- a/examples/features/judge_trace.py+++ b/examples/features/judge_trace.py@@ -15,25 +15,28 @@ from dotenv import load_dotenvload_dotenv()-from browser_use import Agent, ChatBrowserUse+from browser_use import Agent+from browser_use.llm.google.chat import ChatGoogle++# task from GAIA+task = """+If Eliud Kipchoge could maintain his record-making marathon pace indefinitely, how many thousand hours would it take him to run the distance between the Earth and the Moon its closest approach?+Please use the minimum perigee value on the Wikipedia page for the Moon when carrying out your calculation.+Round your result to the nearest 1000 hours and do not use any comma separators if necessary.+"""async def main():- llm = ChatBrowserUse()- task = "Search Google for 'what is browser automation' and tell me the top 3 results"+ llm = ChatGoogle(model='gemini-2.5-flash', temperature=1.0)agent = Agent(task=task,llm=llm,use_judge=True,judge_llm=llm,- # Optional: Add ground_truth="specific answer or criteria" to validate against ground truth+ ground_truth='16', # The TRUE answer is 17 but we put 16 to demonstrate judge can detect when the answer is wrong.)history = await agent.run()- # Get the judgement result- if history.is_judged():- judgement = history.judgement()-if __name__ == '__main__':asyncio.run(main())diff --git a/examples/mert.py b/examples/mert.pynew file mode 100644index 000000000..d4e2ba0e7--- /dev/null+++ b/examples/mert.py@@ -0,0 +1,50 @@+import asyncio+import os+import sys++from browser_use.llm.google.chat import ChatGoogle++sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))++from dotenv import load_dotenv++load_dotenv()++from browser_use import Agent++try:+ from lmnr import Laminar++ Laminar.initialize(project_api_key=os.getenv('LMNR_PROJECT_API_KEY'))+except Exception as e:+ print(f'Error initializing Laminar: {e}')+++# llm = ChatOpenAI(base_url='https://browseruse--browseruse-v0-serve.modal.run/v1',+# model='browser-use/Qwen3-VL-8B-Instruct-301025-1epoch',+# api_key='aitorloveskebabs',+# temperature=1.0,+# dont_force_structured_output=True)++llm = ChatGoogle(model='gemini-flash-latest', temperature=1.0)+# llm = ChatAnthropic(model='claude-sonnet-4-5-20250929', temperature=1.0)+# llm = ChatOpenAI(model='gpt-5-mini', temperature=1.0)++task = """IMPORTANT RULE: Use only clicking by coordinate and sending keys actions. Do not use any other actions. Go to https://levelshealth.typeform.com/waitlist-uk and input John into the first name field and click on OK button using coordinates."""+# task = 'go to example.com and use the extract tool to extract the content of the page.'++task = 'How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.'++task = "The Metropolitan Museum of Art has a portrait in its collection with an accession number of 29.100.5. Of the consecrators and co-consecrators of this portrait's subject as a bishop, what is the name of the one who never became pope?"++task = 'go to https://browser-use.github.io/stress-tests/challenges/angularjs-form.html and go back.'+# Test: llm_screenshot_size should auto-configure to (1400, 850) for Claude Sonnet+agent = Agent(task=task, llm=llm, highlight_elements=True, flash_mode=True, use_judge=True)+++async def main():+ await agent.run(max_steps=30)+++if __name__ == '__main__':+ asyncio.run(main())