Skip to content

Commit

Permalink
[DOCS UPDATE]
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Dec 23, 2024
1 parent b39dfe3 commit c3ba9e5
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 52 deletions.
111 changes: 61 additions & 50 deletions docs/swarms/structs/group_chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,63 +62,74 @@ The GroupChat system consists of several key components:
## Basic Usage

```python

import os
from dotenv import load_dotenv
from swarm_models import OpenAIChat
from swarms import Agent, GroupChat
from loguru import logger

# Load environment variables
load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")

# Initialize LLM
model = OpenAIChat(
openai_api_key=api_key,
model_name="gpt-4o-mini",
temperature=0.1
)
from swarms import Agent, GroupChat, expertise_based

# Create financial analyst agent
financial_analyst = Agent(
agent_name="Financial-Analysis-Agent",
system_prompt="You are a financial analyst specializing in investment strategies.",
llm=model,
max_loops=1,
autosave=False,
dashboard=False,
verbose=True,
dynamic_temperature_enabled=True,
retry_attempts=1,
context_length=200000,
output_type="string"
)

# Create tax advisor agent
tax_advisor = Agent(
agent_name="Tax-Adviser-Agent",
system_prompt="You are a tax adviser providing clear tax guidance.",
llm=model,
max_loops=1,
autosave=False,
dashboard=False,
verbose=True,
dynamic_temperature_enabled=True,
retry_attempts=1,
context_length=200000,
output_type="string"
)
if __name__ == "__main__":

# Initialize group chat
chat = GroupChat(
name="Investment Advisory",
description="Financial and tax analysis group",
agents=[financial_analyst, tax_advisor],
speaker_fn=expertise_based
)
load_dotenv()

# Get the OpenAI API key from the environment variable
api_key = os.getenv("OPENAI_API_KEY")

# Create an instance of the OpenAIChat class
model = OpenAIChat(
openai_api_key=api_key,
model_name="gpt-4o-mini",
temperature=0.1,
)

# Example agents
agent1 = Agent(
agent_name="Financial-Analysis-Agent",
system_prompt="You are a financial analyst specializing in investment strategies.",
llm=model,
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,
)

agent2 = Agent(
agent_name="Tax-Adviser-Agent",
system_prompt="You are a tax adviser who provides clear and concise guidance on tax-related queries.",
llm=model,
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,
)

agents = [agent1, agent2]

chat = GroupChat(
name="Investment Advisory",
description="Financial and tax analysis group",
agents=agents,
speaker_fn=expertise_based,
)

history = chat.run(
"How to optimize tax strategy for investments?"
)
print(history.model_dump_json(indent=2))

# Run conversation
history = chat.run("How to optimize tax strategy for investments?")
```

## Speaker Functions
Expand Down
6 changes: 4 additions & 2 deletions swarm_arange_demo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from swarms.structs.swarm_arange import SwarmRearrange
import os
from swarms import Agent, AgentRearrange

from swarm_models import OpenAIChat

from swarms import Agent, AgentRearrange
from swarms.structs.swarm_arange import SwarmRearrange

# model = Anthropic(anthropic_api_key=os.getenv("ANTHROPIC_API_KEY"))
company = "TGSC"

Expand Down

0 comments on commit c3ba9e5

Please sign in to comment.