Skip to content

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

Fix simple example

Magnus Müller9463e4eb1eaa
diff --git a/browser_use/__init__.py b/browser_use/__init__.py
index c4d09eca8..6d7964abb 100644
--- a/browser_use/__init__.py
+++ b/browser_use/__init__.py
@@ -76,7 +76,7 @@ _LAZY_IMPORTS = {
'BrowserProfile': ('browser_use.browser', 'BrowserProfile'),
# Tools (moderate weight)
'Tools': ('browser_use.tools.service', 'Tools'),
- 'Controller': ('browser_use.tools.service', 'Controller'),
+ 'Controller': ('browser_use.tools.service', 'Controller'), # alias
# DOM service (moderate weight)
'DomService': ('browser_use.dom.service', 'DomService'),
# Chat models (very heavy imports)
diff --git a/browser_use/controller/__init__.py b/browser_use/controller/__init__.py
new file mode 100644
index 000000000..30880d7ca
--- /dev/null
+++ b/browser_use/controller/__init__.py
@@ -0,0 +1,3 @@
+from browser_use.tools.service import Controller
+
+__all__ = ['Controller']
diff --git a/examples/simple.py b/examples/simple.py
index 0b2621d6c..0979c0ff9 100644
--- a/examples/simple.py
+++ b/examples/simple.py
@@ -1,25 +1,8 @@
-import asyncio
-
-from browser_use import Agent, Controller
-
-tools = Controller()
-
-
[email protected]('Ask human for help with a question')
-def ask_human(question: str) -> str:
- answer = input(f'{question} > ')
- return f'The human responded with: {answer}'
-
+from browser_use import Agent, ChatOpenAI
agent = Agent(
task='Ask human for help',
- tools=tools,
+ llm=ChatOpenAI(model='gpt-4.1-mini'),
)
-
-async def main():
- await agent.run()
-
-
-if __name__ == '__main__':
- asyncio.run(main())
+agent.run_sync()