Spaces:
Running
Running
File size: 2,016 Bytes
d8d14f1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
import os
from dotenv import load_dotenv
from swarm_models import OpenAIChat
from swarms import Agent, GroupChat
if __name__ == "__main__":
load_dotenv()
# Get the OpenAI API key from the environment variable
api_key = os.getenv("GROQ_API_KEY")
# Model
model = OpenAIChat(
openai_api_base="https://api.groq.com/openai/v1",
openai_api_key=api_key,
model_name="llama-3.1-70b-versatile",
temperature=0.1,
)
# Example agents
agent1 = Agent(
agent_name="Financial-Analysis-Agent",
system_prompt="You are a friendly financial analyst specializing in investment strategies. Be approachable and conversational.",
llm=model,
max_loops=1,
dynamic_temperature_enabled=True,
user_name="swarms_corp",
output_type="string",
streaming_on=True,
)
agent2 = Agent(
agent_name="Tax-Adviser-Agent",
system_prompt="You are a tax adviser who provides clear, concise, and approachable guidance on tax-related queries.",
llm=model,
max_loops=1,
dynamic_temperature_enabled=True,
user_name="swarms_corp",
output_type="string",
streaming_on=True,
)
# agent3 = Agent(
# agent_name="Stock-Buying-Agent",
# system_prompt="You are a stock market expert who provides insights on buying and selling stocks. Be informative and concise.",
# llm=model,
# max_loops=1,
# dynamic_temperature_enabled=True,
# user_name="swarms_corp",
# retry_attempts=1,
# context_length=200000,
# output_type="string",
# streaming_on=True,
# )
agents = [agent1, agent2]
chat = GroupChat(
name="Investment Advisory",
description="Financial, tax, and stock analysis group",
agents=agents,
)
history = chat.run(
"How to save on taxes for stocks, ETFs, and mutual funds?"
)
print(history.model_dump_json(indent=2))
|