mirror of
https://github.com/microsoft/autogen.git
synced 2025-12-26 14:38:50 +00:00
Remove termination condition from team constructor (#4025)
* Remove termination condition from team constructor * fix usage
This commit is contained in:
parent
cff7d842a6
commit
369ffb511b
@ -33,7 +33,6 @@ class BaseGroupChat(Team, ABC):
|
||||
self,
|
||||
participants: List[ChatAgent],
|
||||
group_chat_manager_class: type[BaseGroupChatManager],
|
||||
termination_condition: TerminationCondition | None = None,
|
||||
):
|
||||
if len(participants) == 0:
|
||||
raise ValueError("At least one participant is required.")
|
||||
@ -42,7 +41,6 @@ class BaseGroupChat(Team, ABC):
|
||||
self._participants = participants
|
||||
self._team_id = str(uuid.uuid4())
|
||||
self._base_group_chat_manager_class = group_chat_manager_class
|
||||
self._termination_condition = termination_condition
|
||||
|
||||
@abstractmethod
|
||||
def _create_group_chat_manager_factory(
|
||||
@ -133,7 +131,7 @@ class BaseGroupChat(Team, ABC):
|
||||
group_topic_type=group_topic_type,
|
||||
participant_topic_types=participant_topic_types,
|
||||
participant_descriptions=participant_descriptions,
|
||||
termination_condition=termination_condition or self._termination_condition,
|
||||
termination_condition=termination_condition,
|
||||
),
|
||||
)
|
||||
# Add subscriptions for the group chat manager.
|
||||
|
||||
@ -103,10 +103,9 @@ class RoundRobinGroupChat(BaseGroupChat):
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, participants: List[ChatAgent], termination_condition: TerminationCondition | None = None):
|
||||
def __init__(self, participants: List[ChatAgent]):
|
||||
super().__init__(
|
||||
participants,
|
||||
termination_condition=termination_condition,
|
||||
group_chat_manager_class=RoundRobinGroupChatManager,
|
||||
)
|
||||
|
||||
|
||||
@ -230,9 +230,7 @@ Read the above conversation. Then select the next role from {participants} to pl
|
||||
""",
|
||||
allow_repeated_speaker: bool = False,
|
||||
):
|
||||
super().__init__(
|
||||
participants, termination_condition=termination_condition, group_chat_manager_class=SelectorGroupChatManager
|
||||
)
|
||||
super().__init__(participants, group_chat_manager_class=SelectorGroupChatManager)
|
||||
# Validate the participants.
|
||||
if len(participants) < 2:
|
||||
raise ValueError("At least two participants are required for SelectorGroupChat.")
|
||||
|
||||
@ -85,10 +85,8 @@ class Swarm(BaseGroupChat):
|
||||
print(message)
|
||||
"""
|
||||
|
||||
def __init__(self, participants: List[ChatAgent], termination_condition: TerminationCondition | None = None):
|
||||
super().__init__(
|
||||
participants, termination_condition=termination_condition, group_chat_manager_class=SwarmGroupChatManager
|
||||
)
|
||||
def __init__(self, participants: List[ChatAgent]):
|
||||
super().__init__(participants, group_chat_manager_class=SwarmGroupChatManager)
|
||||
# The first participant must be able to produce handoff messages.
|
||||
first_participant = self._participants[0]
|
||||
if HandoffMessage not in first_participant.produced_message_types:
|
||||
|
||||
@ -516,8 +516,8 @@ async def test_swarm_handoff() -> None:
|
||||
second_agent = _HandOffAgent("second_agent", description="second agent", next_agent="third_agent")
|
||||
third_agent = _HandOffAgent("third_agent", description="third agent", next_agent="first_agent")
|
||||
|
||||
team = Swarm([second_agent, first_agent, third_agent], termination_condition=MaxMessageTermination(6))
|
||||
result = await team.run("task")
|
||||
team = Swarm([second_agent, first_agent, third_agent])
|
||||
result = await team.run("task", termination_condition=MaxMessageTermination(6))
|
||||
assert len(result.messages) == 6
|
||||
assert result.messages[0].content == "task"
|
||||
assert result.messages[1].content == "Transferred to third_agent."
|
||||
|
||||
@ -81,10 +81,11 @@
|
||||
")\n",
|
||||
"\n",
|
||||
"# add the agent to a team\n",
|
||||
"agent_team = RoundRobinGroupChat([weather_agent], termination_condition=MaxMessageTermination(max_messages=2))\n",
|
||||
"agent_team = RoundRobinGroupChat([weather_agent])\n",
|
||||
"# Note: if running in a Python file directly you'll need to use asyncio.run(agent_team.run(...)) instead of await agent_team.run(...)\n",
|
||||
"result = await agent_team.run(\n",
|
||||
" task=\"What is the weather in New York?\",\n",
|
||||
" termination_condition=MaxMessageTermination(max_messages=2),\n",
|
||||
")\n",
|
||||
"print(\"\\n\", result)"
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user