parent
5af454020a
commit
cc9ea26aaf
@ -0,0 +1,82 @@
|
||||
# Groupchat Example
|
||||
|
||||
- Import required modules
|
||||
|
||||
- Configure your agents first
|
||||
|
||||
- Set your api keys for your model provider in the `.env` file such as `OPENAI_API_KEY="sk-"`
|
||||
|
||||
- Conigure `GroupChat` with it's various settings
|
||||
|
||||
|
||||
## Install
|
||||
```bash
|
||||
pip install swarms
|
||||
```
|
||||
|
||||
---------
|
||||
|
||||
## Main Code
|
||||
|
||||
```python
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
from swarms import Agent, GroupChat
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Get the OpenAI API key from the environment variable
|
||||
api_key = os.getenv("OPENAI_API_KEY")
|
||||
|
||||
# Example agents
|
||||
agent1 = Agent(
|
||||
agent_name="Expense-Analysis-Agent",
|
||||
description="You are an accounting agent specializing in analyzing potential expenses.",
|
||||
model_name="gpt-4o-mini",
|
||||
max_loops=1,
|
||||
autosave=False,
|
||||
dashboard=False,
|
||||
verbose=True,
|
||||
dynamic_temperature_enabled=True,
|
||||
user_name="swarms_corp",
|
||||
retry_attempts=1,
|
||||
context_length=200000,
|
||||
output_type="string",
|
||||
streaming_on=False,
|
||||
max_tokens=15000,
|
||||
)
|
||||
|
||||
agent2 = Agent(
|
||||
agent_name="Budget-Adviser-Agent",
|
||||
description="You are a budget adviser who provides insights on managing and optimizing expenses.",
|
||||
model_name="gpt-4o-mini",
|
||||
max_loops=1,
|
||||
autosave=False,
|
||||
dashboard=False,
|
||||
verbose=True,
|
||||
dynamic_temperature_enabled=True,
|
||||
user_name="swarms_corp",
|
||||
retry_attempts=1,
|
||||
context_length=200000,
|
||||
output_type="string",
|
||||
streaming_on=False,
|
||||
max_tokens=15000,
|
||||
)
|
||||
|
||||
agents = [agent1, agent2]
|
||||
|
||||
chat = GroupChat(
|
||||
name="Expense Advisory",
|
||||
description="Accounting group focused on discussing potential expenses",
|
||||
agents=agents,
|
||||
max_loops=1,
|
||||
output_type="all",
|
||||
)
|
||||
|
||||
history = chat.run(
|
||||
"What potential expenses should we consider for the upcoming quarter? Please collaborate to outline a comprehensive list."
|
||||
)
|
||||
```
|
@ -0,0 +1,65 @@
|
||||
# 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.
|
||||
|
||||
"""
|
||||
)
|
||||
|
||||
```
|
Loading…
Reference in new issue