Skip to content

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

created try.py and downloaded readme

Gregor Žuničd1c78a7d2aa0
diff --git a/README.md b/README.md
index 5328459fb..dec65176c 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,7 @@ _Let LLMs interact with websites naturally_
## 🎥 Live Demos
Watch Browser-Use tackle real-world tasks:
+
<div>
<a href="https://www.loom.com/share/3ddba106c1fd4fd38c314881fb7d3d78">
<p>Library | Loom - 5 November 2024 - Watch Video</p>
@@ -35,15 +36,6 @@ Watch Browser-Use tackle real-world tasks:
<img style="max-width:300px;" src="https://cdn.loom.com/sessions/thumbnails/3ddba106c1fd4fd38c314881fb7d3d78-7d8bc50585272d46-full-play.gif">
</a>
</div>
-<div>
- <a href="https://www.loom.com/share/93015893157249d39d96a8de604e3719">
- <p>Library | Loom - 5 November 2024 - Watch Video</p>
- </a>
- <a href="https://www.loom.com/share/93015893157249d39d96a8de604e3719">
- <img style="max-width:300px;" src="https://cdn.loom.com/sessions/thumbnails/93015893157249d39d96a8de604e3719-cbda1dbe844472b8-full-play.gif">
- </a>
- </div>
-
## 🚀 Key Features
@@ -125,6 +117,30 @@ print(founders)
You can use the `history` to run the agents again deterministically.
+## Simple Run
+
+You can run any of the examples using the command line interface:
+
+```bash
+python examples/try.py "Your query here" --provider [openai|anthropic]
+```
+
+### Anthropic
+
+You need to add `ANTHROPIC_API_KEY` to your environment variables. Example usage:
+
+```bash
+python examples/try.py "Find cheapest flight from London to Paris" --provider anthropic
+```
+
+### OpenAI
+
+You need to add `OPENAI_API_KEY` to your environment variables. Example usage:
+
+```bash
+python examples/try.py "Search for top AI companies" --provider openai
+```
+
## 🤖 Supported Models
All LangChain chat models are supported.
diff --git a/examples/try.py b/examples/try.py
new file mode 100644
index 000000000..9ada99486
--- /dev/null
+++ b/examples/try.py
@@ -0,0 +1,62 @@
+"""
+Simple try of the agent.
+
+@dev You need to add ANTHROPIC_API_KEY to your environment variables.
+"""
+
+import logging
+import os
+import sys
+
+from langchain_anthropic import ChatAnthropic
+from langchain_openai import ChatOpenAI
+
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+import asyncio
+
+from src import Agent
+
+import argparse
+
+logging.basicConfig(level=logging.INFO)
+
+
+def get_llm(provider: str):
+ if provider == 'anthropic':
+ return ChatAnthropic(
+ model_name='claude-3-5-sonnet-20240620', timeout=25, stop=None, temperature=0.3
+ )
+ elif provider == 'openai':
+ return ChatOpenAI(model='gpt-4')
+ else:
+ raise ValueError(f'Unsupported provider: {provider}')
+
+
+parser = argparse.ArgumentParser()
+parser.add_argument('query', type=str, help='The query to process')
+parser.add_argument(
+ '--provider',
+ type=str,
+ choices=['openai', 'anthropic'],
+ default='openai',
+ help='The model provider to use (default: openai)',
+)
+
+args = parser.parse_args()
+
+llm = get_llm(args.provider)
+
+agent = Agent(
+ task=args.query,
+ llm=llm,
+)
+
+
+async def main():
+ result, history = await agent.run()
+ print(result)
+ print(history)
+
+
+asyncio.run(main())
diff --git a/src/agent/service.py b/src/agent/service.py
index 165f2821f..e8448739f 100644
--- a/src/agent/service.py
+++ b/src/agent/service.py
@@ -31,7 +31,7 @@ class AgentService:
task: str,
llm: BaseChatModel,
controller: ControllerService | None = None,
- use_vision: bool = False,
+ use_vision: bool = True,
save_conversation_path: str | None = None,
):
"""