2024-11-05 10:51:00
github.com
Watch Browser-Use tackle real-world tasks:
- 🤖 Universal LLM Support – Works with any Language Model
- 🎯 Smart Element Detection – Automatically finds interactive elements
- 📑 Multi-Tab Management – Seamless handling of browser tabs
- 🔍 XPath Extraction – No more manual DevTools inspection
- 👁️ Vision Model Support – Process visual page information
- 🛠️ Customizable Actions – Add your own browser interactions
Create a virtual environment and install the dependencies:
# I recommend using uv
pip install -r requirements.txt
Add your API keys to the .env
file.
You can use any LLM model that is supported by LangChain by adding correct environment variables. Head over to the langchain models page to see all available models.
from src import Agent
from langchain_openai import ChatOpenAI
# Initialize browser agent
agent = Agent(
task='Find cheapest flight from London to Kyrgyzstan and return the url.',
llm=ChatOpenAI(model='gpt-4o'),
)
# Let it work its magic
await agent.run()
You can persist the browser across multiple agents and chain them together.
from langchain_anthropic import ChatAnthropic
from src import Agent, Controller
# Persist the browser state across agents
controller = Controller()
# Initialize browser agent
agent1 = Agent(
task='Open 5 VCs websites in the New York area.',
llm=ChatAnthropic(model_name='claude-3-sonnet', timeout=25, stop=None, temperature=0.3),
controller=controller,
)
agent2 = Agent(
task='Give me the names of the founders of the companies in all tabs.',
llm=ChatAnthropic(model_name='claude-3-sonnet', timeout=25, stop=None, temperature=0.3),
controller=controller,
)
# Let it work its magic
await agent1.run()
founders, history = await agent2.run()
print(founders)
You can use the history
to run the agents again deterministically.
You can run any of the examples using the command line interface:
python examples/try.py "Your query here" --provider [openai|anthropic]
You need to add ANTHROPIC_API_KEY
to your environment variables. Example usage:
python examples/try.py "Find cheapest flight from London to Paris" --provider anthropic
You need to add OPENAI_API_KEY
to your environment variables. Example usage:
python examples/try.py "Search for top AI companies" --provider openai
All LangChain chat models are supported.
- GPT-4o
- GPT-4o Mini
- Claude 3.5 Sonnet
- LLama 3.1 405B
Contributions are welcome! Also feel free to open issues for any bugs or feature requests.
Star ⭐ this repo if you find it useful!
Made with ❤️ by the Browser-Use team
Support Techcratic
If you find value in Techcratic’s insights and articles, consider supporting us with Bitcoin. Your support helps me, as a solo operator, continue delivering high-quality content while managing all the technical aspects, from server maintenance to blog writing, future updates, and improvements. Support Innovation! Thank you.
Bitcoin Address:
bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge
Please verify this address before sending funds.
Bitcoin QR Code
Simply scan the QR code below to support Techcratic.
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.