[DOCS UPDATE]

pull/704/head
Kye Gomez 2 weeks ago
parent b39dfe3e58
commit c3ba9e55bd

@ -62,25 +62,29 @@ The GroupChat system consists of several key components:
## Basic Usage ## Basic Usage
```python ```python
import os import os
from dotenv import load_dotenv from dotenv import load_dotenv
from swarm_models import OpenAIChat from swarm_models import OpenAIChat
from swarms import Agent, GroupChat from swarms import Agent, GroupChat, expertise_based
from loguru import logger
if __name__ == "__main__":
# Load environment variables load_dotenv()
load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")
# Initialize LLM # Get the OpenAI API key from the environment variable
model = OpenAIChat( api_key = os.getenv("OPENAI_API_KEY")
# Create an instance of the OpenAIChat class
model = OpenAIChat(
openai_api_key=api_key, openai_api_key=api_key,
model_name="gpt-4o-mini", model_name="gpt-4o-mini",
temperature=0.1 temperature=0.1,
) )
# Create financial analyst agent # Example agents
financial_analyst = Agent( agent1 = Agent(
agent_name="Financial-Analysis-Agent", agent_name="Financial-Analysis-Agent",
system_prompt="You are a financial analyst specializing in investment strategies.", system_prompt="You are a financial analyst specializing in investment strategies.",
llm=model, llm=model,
@ -89,36 +93,43 @@ financial_analyst = Agent(
dashboard=False, dashboard=False,
verbose=True, verbose=True,
dynamic_temperature_enabled=True, dynamic_temperature_enabled=True,
user_name="swarms_corp",
retry_attempts=1, retry_attempts=1,
context_length=200000, context_length=200000,
output_type="string" output_type="string",
) streaming_on=False,
)
# Create tax advisor agent agent2 = Agent(
tax_advisor = Agent(
agent_name="Tax-Adviser-Agent", agent_name="Tax-Adviser-Agent",
system_prompt="You are a tax adviser providing clear tax guidance.", system_prompt="You are a tax adviser who provides clear and concise guidance on tax-related queries.",
llm=model, llm=model,
max_loops=1, max_loops=1,
autosave=False, autosave=False,
dashboard=False, dashboard=False,
verbose=True, verbose=True,
dynamic_temperature_enabled=True, dynamic_temperature_enabled=True,
user_name="swarms_corp",
retry_attempts=1, retry_attempts=1,
context_length=200000, context_length=200000,
output_type="string" output_type="string",
) streaming_on=False,
)
# Initialize group chat agents = [agent1, agent2]
chat = GroupChat(
chat = GroupChat(
name="Investment Advisory", name="Investment Advisory",
description="Financial and tax analysis group", description="Financial and tax analysis group",
agents=[financial_analyst, tax_advisor], agents=agents,
speaker_fn=expertise_based 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 ## Speaker Functions

@ -1,8 +1,10 @@
from swarms.structs.swarm_arange import SwarmRearrange
import os import os
from swarms import Agent, AgentRearrange
from swarm_models import OpenAIChat 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")) # model = Anthropic(anthropic_api_key=os.getenv("ANTHROPIC_API_KEY"))
company = "TGSC" company = "TGSC"

Loading…
Cancel
Save