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
run pre-commit
Anirudha6192cea6aef79cd
diff --git a/examples/custom-functions/file_upload.py b/examples/custom-functions/file_upload.pyindex 827c0b637..d79f33cd5 100644--- a/examples/custom-functions/file_upload.py+++ b/examples/custom-functions/file_upload.py@@ -70,7 +70,7 @@ async def read_file(path: str, available_file_paths: list[str]):if path not in available_file_paths:return ActionResult(error=f'File path {path} is not available')- async with (await anyio.open_file(path, 'r')) as f:+ async with await anyio.open_file(path, 'r') as f:content = await f.read()msg = f'File content: {content}'logger.info(msg)diff --git a/tests/test_vision.py b/tests/test_vision.pyindex cc0b2568c..f0a9e9205 100644--- a/tests/test_vision.py+++ b/tests/test_vision.py@@ -14,10 +14,11 @@ from browser_use.browser.browser import Browser, BrowserConfigsys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))+import asyncio+from langchain_openai import ChatOpenAIfrom browser_use import Agent, AgentHistoryList, Controller-import asynciollm = ChatOpenAI(model='gpt-4o')controller = Controller()@@ -42,22 +43,22 @@ async def done(text: str) -> str:@pytest.fixture(scope='function')def event_loop():- """Create an instance of the default event loop for each test case."""- loop = asyncio.get_event_loop_policy().new_event_loop()- yield loop- loop.close()+ """Create an instance of the default event loop for each test case."""+ loop = asyncio.get_event_loop_policy().new_event_loop()+ yield loop+ loop.close()@pytest.mark.skip(reason='this is for local testing only')async def test_vision():- agent = Agent(- task='call explain_screen all the time the user asks you questions e.g. about the page like bbox which you see are labels - your task is to explain it and get the next question',- llm=llm,- controller=controller,- browser=Browser(config=BrowserConfig(disable_security=True, headless=False)),- )- try:- history: AgentHistoryList = await agent.run(20)- finally:- # Make sure to close the browser- await agent.browser.close()+ agent = Agent(+ task='call explain_screen all the time the user asks you questions e.g. about the page like bbox which you see are labels - your task is to explain it and get the next question',+ llm=llm,+ controller=controller,+ browser=Browser(config=BrowserConfig(disable_security=True, headless=False)),+ )+ try:+ history: AgentHistoryList = await agent.run(20)+ finally:+ # Make sure to close the browser+ await agent.browser.close()