mirror of
https://github.com/browser-use/browser-use
synced 2026-04-22 17:45:09 +02:00
Fix simple example
This commit is contained in:
@@ -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)
|
||||
|
||||
3
browser_use/controller/__init__.py
Normal file
3
browser_use/controller/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from browser_use.tools.service import Controller
|
||||
|
||||
__all__ = ['Controller']
|
||||
@@ -1,25 +1,8 @@
|
||||
import asyncio
|
||||
|
||||
from browser_use import Agent, Controller
|
||||
|
||||
tools = Controller()
|
||||
|
||||
|
||||
@tools.action('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()
|
||||
|
||||
Reference in New Issue
Block a user