You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.3 KiB
65 lines
1.3 KiB
# Swarms x Browser Use
|
|
|
|
- Import required modules
|
|
|
|
- Configure your agent first by making a new class
|
|
|
|
- Set your api keys for your model provider in the `.env` file such as `OPENAI_API_KEY="sk-"`
|
|
|
|
- Conigure your `ConcurrentWorkflow`
|
|
|
|
## Install
|
|
|
|
```bash
|
|
pip install swarms browser-use langchain-openai
|
|
```
|
|
--------
|
|
|
|
|
|
## Main
|
|
```python
|
|
import asyncio
|
|
|
|
from browser_use import Agent
|
|
from dotenv import load_dotenv
|
|
from langchain_openai import ChatOpenAI
|
|
|
|
from swarms import ConcurrentWorkflow
|
|
|
|
load_dotenv()
|
|
|
|
|
|
class BrowserAgent:
|
|
def __init__(self, agent_name: str = "BrowserAgent"):
|
|
self.agent_name = agent_name
|
|
|
|
async def browser_agent_test(self, task: str):
|
|
agent = Agent(
|
|
task=task,
|
|
llm=ChatOpenAI(model="gpt-4o"),
|
|
)
|
|
result = await agent.run()
|
|
return result
|
|
|
|
def run(self, task: str):
|
|
return asyncio.run(self.browser_agent_test(task))
|
|
|
|
|
|
swarm = ConcurrentWorkflow(
|
|
agents=[BrowserAgent() for _ in range(3)],
|
|
)
|
|
|
|
swarm.run(
|
|
"""
|
|
Go to pump.fun.
|
|
|
|
2. Make an account: use email: "test@test.com" and password: "test1234"
|
|
|
|
3. Make a coin called and give it a cool description and etc. Fill in the form
|
|
|
|
4. Sit back and watch the coin grow in value.
|
|
|
|
"""
|
|
)
|
|
|
|
``` |