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.
swarms/groupchat.py

25 lines
654 B

from swarms.structs import Flow
from swarms.models import OpenAIChat
from swarms.swarms.groupchat import GroupChat
from swarms.agents import SimpleAgent
api_key = ""
llm = OpenAIChat(
openai_api_key=api_key,
)
agent1 = SimpleAgent("Captain Price", Flow(llm=llm, max_loops=4))
agent2 = SimpleAgent("John Mactavis", Flow(llm=llm, max_loops=4))
# Create a groupchat with the 2 agents
chat = GroupChat([agent1, agent2])
# Assign duties to the agents
chat.assign_duty(agent1.name, "Buy the groceries")
chat.assign_duty(agent2.name, "Clean the house")
# Initate a chat
response = chat.run("Captain Price", "Hello, how are you John?")
print(response)