Skip to content

Commit

Permalink
7.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Feb 14, 2025
1 parent d8e0690 commit 43c5845
Show file tree
Hide file tree
Showing 9 changed files with 775 additions and 769 deletions.
36 changes: 36 additions & 0 deletions group_chat_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from swarms.structs.agent import Agent
from swarms.structs.groupchat import GroupChat


if __name__ == "__main__":

# Example agents
agent1 = Agent(
agent_name="Financial-Analysis-Agent",
system_prompt="You are a financial analyst specializing in investment strategies.",
model_name="gpt-4o",
max_loops=1,
dynamic_temperature_enabled=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.",
model_name="gpt-4o",
max_loops=1,
dynamic_temperature_enabled=True,
)

agents = [agent1, agent2]

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

history = chat.run(
"How to optimize tax strategy for investments?"
)
print(history)
15 changes: 7 additions & 8 deletions majority_voting_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
agent_description="Personal finance advisor focused on market analysis",
system_prompt="You are a financial advisor specializing in market analysis and investment opportunities.",
max_loops=1,
model_name="gpt-4o"
model_name="gpt-4o",
),
Agent(
agent_name="Risk-Assessment-Agent",
agent_name="Risk-Assessment-Agent",
agent_description="Risk analysis and portfolio management expert",
system_prompt="You are a risk assessment expert focused on evaluating investment risks and portfolio diversification.",
max_loops=1,
model_name="gpt-4o"
model_name="gpt-4o",
),
Agent(
agent_name="Tech-Investment-Agent",
agent_description="Technology sector investment specialist",
system_prompt="You are a technology investment specialist focused on AI, emerging tech, and growth opportunities.",
max_loops=1,
model_name="gpt-4o"
)
model_name="gpt-4o",
),
]


Expand All @@ -31,7 +31,7 @@
agent_description="Consensus agent focused on analyzing investment advice",
system_prompt="You are a consensus agent focused on analyzing investment advice and providing a final answer.",
max_loops=1,
model_name="gpt-4o"
model_name="gpt-4o",
)

# Create majority voting system
Expand All @@ -40,13 +40,12 @@
description="Multi-agent system for investment advice",
agents=agents,
verbose=True,
consensus_agent=consensus_agent
consensus_agent=consensus_agent,
)

# Run the analysis with majority voting
result = majority_voting.run(
task="Create a table of super high growth opportunities for AI. I have $40k to invest in ETFs, index funds, and more. Please create a table in markdown.",
correct_answer="" # Optional evaluation metric
)

print(result)
14 changes: 1 addition & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "swarms"
version = "7.1.7"
version = "7.1.9"
description = "Swarms - TGSC"
license = "MIT"
authors = ["Kye Gomez <[email protected]>"]
Expand Down Expand Up @@ -73,21 +73,9 @@ docstring_parser = "0.16" # TODO:
tiktoken = "*"
networkx = "*"
aiofiles = "*"
# chromadb = "*"
rich = "*"
numpy = "*"
litellm = "*"
# sentence-transformers = "*"


# # All optional dependencies for convenience
# all = [
# "torch",
# "transformers",
# "litellm"
# ]



[tool.poetry.scripts]
swarms = "swarms.cli.main:main"
Expand Down
6 changes: 0 additions & 6 deletions swarms/structs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
NodeType,
)
from swarms.structs.groupchat import (
AgentResponse,
ChatHistory,
ChatTurn,
GroupChat,
expertise_based,
)
Expand Down Expand Up @@ -138,9 +135,6 @@
"run_agents_with_tasks_concurrently",
"showcase_available_agents",
"GroupChat",
"ChatHistory",
"ChatTurn",
"AgentResponse",
"expertise_based",
"MultiAgentRouter",
"MemeAgentGenerator",
Expand Down
19 changes: 16 additions & 3 deletions swarms/structs/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,23 @@ def get_visible_messages(self, agent: "Agent", turn: int):
visible_messages.append(message)
return visible_messages

def get_last_message_as_string(self):
# fetch the last message from the conversation history with the agent name and the message of the agent
return f"{self.conversation_history[-1]['role']}: {self.conversation_history[-1]['content']}"

# # Example usage
# conversation = Conversation()
# conversation.add("user", "Hello, how are you?")
def return_messages_as_list(self):
# we must concat the role and the content of the message
return [
f"{message['role']}: {message['content']}"
for message in self.conversation_history
]


# Example usage
conversation = Conversation()
conversation.add("user", "Hello, how are you?")
# print(conversation.get_last_message_as_string())
# print(conversation.return_messages_as_list())
# conversation.add("assistant", "I am doing well, thanks.")
# # print(conversation.to_json())
# print(type(conversation.to_dict()))
Expand Down
Loading

0 comments on commit 43c5845

Please sign in to comment.