You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.0 KiB
32 lines
1.0 KiB
from swarms import OpenAIChat
|
|
from swarms.structs.agent import Agent
|
|
from swarms.structs.message_pool import MessagePool
|
|
|
|
# Create agents
|
|
agent1 = Agent(llm=OpenAIChat(), agent_name="agent1")
|
|
agent2 = Agent(llm=OpenAIChat(), agent_name="agent2")
|
|
agent3 = Agent(llm=OpenAIChat(), agent_name="agent3")
|
|
|
|
# Create moderator agent
|
|
moderator = Agent(agent_name="moderator")
|
|
|
|
# Create a list of agents
|
|
agents = [agent1, agent2, agent3]
|
|
|
|
# Create a message pool with 5 turns
|
|
message_pool = MessagePool(agents=agents, moderator=moderator, turns=5)
|
|
|
|
# Add messages to the message pool
|
|
message_pool.add(agent=agent1, content="Hello, agent2!", turn=1)
|
|
message_pool.add(agent=agent2, content="Hello, agent1!", turn=1)
|
|
message_pool.add(agent=agent3, content="Hello, agent1!", turn=1)
|
|
|
|
# Get all messages in the message pool
|
|
message_pool.get_all_messages()
|
|
|
|
# Get visible messages for agent1 in turn 1
|
|
message_pool.get_visible_messages(agent=agent1, turn=1)
|
|
|
|
# Get visible messages for agent2 in turn 1
|
|
message_pool.get_visible_messages(agent=agent2, turn=1)
|