From b1834a62f875686cd5e6aea5d373880b40bc2829 Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Mon, 23 Dec 2024 11:33:04 -0800 Subject: [PATCH] [DOCS][CLEANUP] --- crypto_tax.py | 56 +++++++++++++++++++++++++++++ group_chat_example.py | 42 ++++++++++++---------- pyproject.toml | 2 +- swarm_arange_demo.py | 2 +- swarms/structs/__init__.py | 2 ++ swarms/structs/spreadsheet_swarm.py | 5 +-- 6 files changed, 84 insertions(+), 25 deletions(-) create mode 100644 crypto_tax.py diff --git a/crypto_tax.py b/crypto_tax.py new file mode 100644 index 00000000..cf887e31 --- /dev/null +++ b/crypto_tax.py @@ -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)) diff --git a/group_chat_example.py b/group_chat_example.py index dbe508bb..830594f4 100644 --- a/group_chat_example.py +++ b/group_chat_example.py @@ -10,58 +10,62 @@ if __name__ == "__main__": load_dotenv() # 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( + openai_api_base="https://api.groq.com/openai/v1", openai_api_key=api_key, - model_name="gpt-4o-mini", + model_name="llama-3.1-70b-versatile", temperature=0.1, ) # Example agents agent1 = 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, 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, + streaming_on=True, ) agent2 = 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, 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, + 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 and tax analysis group", + description="Financial, tax, and stock analysis group", agents=agents, speaker_fn=expertise_based, ) 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)) diff --git a/pyproject.toml b/pyproject.toml index 693c6886..b4c7cf98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "6.7.6" +version = "6.7.7" description = "Swarms - TGSC" license = "MIT" authors = ["Kye Gomez "] diff --git a/swarm_arange_demo.py b/swarm_arange_demo.py index d9457ac5..f900abcc 100644 --- a/swarm_arange_demo.py +++ b/swarm_arange_demo.py @@ -213,6 +213,6 @@ swarm_arrange = SwarmRearrange( print( 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" ) ) diff --git a/swarms/structs/__init__.py b/swarms/structs/__init__.py index 234fb72c..dbae2f48 100644 --- a/swarms/structs/__init__.py +++ b/swarms/structs/__init__.py @@ -17,6 +17,7 @@ from swarms.structs.groupchat import ( ChatHistory, ChatTurn, AgentResponse, + expertise_based ) from swarms.structs.majority_voting import ( MajorityVoting, @@ -152,4 +153,5 @@ __all__ = [ "ChatHistory", "ChatTurn", "AgentResponse", + "expertise_based", ] diff --git a/swarms/structs/spreadsheet_swarm.py b/swarms/structs/spreadsheet_swarm.py index 2e691f78..2fb298e6 100644 --- a/swarms/structs/spreadsheet_swarm.py +++ b/swarms/structs/spreadsheet_swarm.py @@ -21,10 +21,7 @@ uuid_hex = uuid.uuid4().hex # --------------- NEW CHANGE START --------------- # Format time variable to be compatible across operating systems -formatted_time = 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" +formatted_time = datetime.datetime.now().strftime("%Y-%m-%dT%H-%M-%S") # --------------- NEW CHANGE END --------------- class AgentOutput(BaseModel):