[DOCS][CLEANUP]

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

@ -0,0 +1,56 @@
import os
from dotenv import load_dotenv
from swarm_models import OpenAIChat
from swarms import Agent, GroupChat, expertise_based
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="Crypto-Tax-Optimization-Agent",
system_prompt="You are a friendly tax expert specializing in cryptocurrency investments. Provide approachable insights on optimizing tax savings for crypto transactions.",
llm=model,
max_loops=1,
dynamic_temperature_enabled=True,
user_name="User",
output_type="string",
streaming_on=True,
)
agent2 = Agent(
agent_name="Crypto-Investment-Strategies-Agent",
system_prompt="You are a conversational financial analyst focused on cryptocurrency investments. Offer debatable advice on investment strategies that minimize tax liabilities.",
llm=model,
max_loops=1,
dynamic_temperature_enabled=True,
user_name="User",
output_type="string",
streaming_on=True,
)
agents = [agent1, agent2]
chat = GroupChat(
name="Crypto Tax Optimization Debate",
description="Debate on optimizing tax savings for cryptocurrency transactions and investments",
agents=agents,
speaker_fn=expertise_based,
)
history = chat.run(
"How can one optimize tax savings for cryptocurrency transactions and investments? I bought some Bitcoin and Ethereum last year and want to minimize my tax liabilities this year."
)
print(history.model_dump_json(indent=2))

@ -10,58 +10,62 @@ if __name__ == "__main__":
load_dotenv() load_dotenv()
# Get the OpenAI API key from the environment variable # Get the OpenAI API key from the environment variable
api_key = os.getenv("OPENAI_API_KEY") api_key = os.getenv("GROQ_API_KEY")
# Create an instance of the OpenAIChat class # Model
model = OpenAIChat( model = OpenAIChat(
openai_api_base="https://api.groq.com/openai/v1",
openai_api_key=api_key, openai_api_key=api_key,
model_name="gpt-4o-mini", model_name="llama-3.1-70b-versatile",
temperature=0.1, temperature=0.1,
) )
# Example agents # Example agents
agent1 = 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 friendly financial analyst specializing in investment strategies. Be approachable and conversational.",
llm=model, llm=model,
max_loops=1, max_loops=1,
autosave=False,
dashboard=False,
verbose=True,
dynamic_temperature_enabled=True, dynamic_temperature_enabled=True,
user_name="swarms_corp", user_name="swarms_corp",
retry_attempts=1,
context_length=200000,
output_type="string", output_type="string",
streaming_on=False, streaming_on=True,
) )
agent2 = Agent( agent2 = Agent(
agent_name="Tax-Adviser-Agent", agent_name="Tax-Adviser-Agent",
system_prompt="You are a tax adviser who provides clear and concise guidance on tax-related queries.", system_prompt="You are a tax adviser who provides clear, concise, and approachable guidance on tax-related queries.",
llm=model, llm=model,
max_loops=1, max_loops=1,
autosave=False,
dashboard=False,
verbose=True,
dynamic_temperature_enabled=True, dynamic_temperature_enabled=True,
user_name="swarms_corp", user_name="swarms_corp",
retry_attempts=1,
context_length=200000,
output_type="string", output_type="string",
streaming_on=False, 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] agents = [agent1, agent2]
chat = GroupChat( chat = GroupChat(
name="Investment Advisory", name="Investment Advisory",
description="Financial and tax analysis group", description="Financial, tax, and stock analysis group",
agents=agents, agents=agents,
speaker_fn=expertise_based, speaker_fn=expertise_based,
) )
history = chat.run( history = chat.run(
"How to optimize tax strategy for investments?" "How to save on taxes for stocks, ETFs, and mutual funds?"
) )
print(history.model_dump_json(indent=2)) print(history.model_dump_json(indent=2))

@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry] [tool.poetry]
name = "swarms" name = "swarms"
version = "6.7.6" version = "6.7.7"
description = "Swarms - TGSC" description = "Swarms - TGSC"
license = "MIT" license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"] authors = ["Kye Gomez <kye@apac.ai>"]

@ -213,6 +213,6 @@ swarm_arrange = SwarmRearrange(
print( print(
swarm_arrange.run( swarm_arrange.run(
"Analyze swarms, 150k revenue with 45m+ agents build, with 1.4m downloads since march 2024" "Analyze AI ETFs, focusing on their performance, market trends, and potential for growth"
) )
) )

@ -17,6 +17,7 @@ from swarms.structs.groupchat import (
ChatHistory, ChatHistory,
ChatTurn, ChatTurn,
AgentResponse, AgentResponse,
expertise_based
) )
from swarms.structs.majority_voting import ( from swarms.structs.majority_voting import (
MajorityVoting, MajorityVoting,
@ -152,4 +153,5 @@ __all__ = [
"ChatHistory", "ChatHistory",
"ChatTurn", "ChatTurn",
"AgentResponse", "AgentResponse",
"expertise_based",
] ]

@ -21,10 +21,7 @@ uuid_hex = uuid.uuid4().hex
# --------------- NEW CHANGE START --------------- # --------------- NEW CHANGE START ---------------
# Format time variable to be compatible across operating systems # Format time variable to be compatible across operating systems
formatted_time = datetime.now().strftime("%Y-%m-%dT%H-%M-%S") formatted_time = datetime.datetime.now().strftime("%Y-%m-%dT%H-%M-%S")
# Create the save file path with the formatted time and UUID hex
self.save_file_path = f"spreadsheet_swarm_{formatted_time}_run_id_{uuid_hex}.csv"
# --------------- NEW CHANGE END --------------- # --------------- NEW CHANGE END ---------------
class AgentOutput(BaseModel): class AgentOutput(BaseModel):

Loading…
Cancel
Save