Skip to content

Commit 27e1656

Browse files
Remove redundancy code and improve validation logics in AgentChat (#6190)
Signed-off-by: zhanluxianshen <[email protected]> Co-authored-by: Eric Zhu <[email protected]>
1 parent 3932126 commit 27e1656

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

python/packages/autogen-agentchat/src/autogen_agentchat/messages.py

-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ def create(self, data: Mapping[str, Any]) -> BaseAgentEvent | BaseChatMessage:
432432
"BaseChatMessage",
433433
"BaseAgentEvent",
434434
"BaseTextChatMessage",
435-
"BaseChatMessage",
436435
"StructuredContentType",
437436
"StructuredMessage",
438437
"HandoffMessage",

python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat_manager.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,17 @@ def __init__(
5555
GroupChatReset,
5656
],
5757
)
58-
self._name = name
59-
self._group_topic_type = group_topic_type
60-
self._output_topic_type = output_topic_type
58+
if max_turns is not None and max_turns <= 0:
59+
raise ValueError("The maximum number of turns must be greater than 0.")
6160
if len(participant_topic_types) != len(participant_descriptions):
6261
raise ValueError("The number of participant topic types, agent types, and descriptions must be the same.")
6362
if len(set(participant_topic_types)) != len(participant_topic_types):
6463
raise ValueError("The participant topic types must be unique.")
6564
if group_topic_type in participant_topic_types:
6665
raise ValueError("The group topic type must not be in the participant topic types.")
66+
self._name = name
67+
self._group_topic_type = group_topic_type
68+
self._output_topic_type = output_topic_type
6769
self._participant_names = participant_names
6870
self._participant_name_to_topic_type = {
6971
name: topic_type for name, topic_type in zip(participant_names, participant_topic_types, strict=True)
@@ -72,8 +74,6 @@ def __init__(
7274
self._message_thread: List[BaseAgentEvent | BaseChatMessage] = []
7375
self._output_message_queue = output_message_queue
7476
self._termination_condition = termination_condition
75-
if max_turns is not None and max_turns <= 0:
76-
raise ValueError("The maximum number of turns must be greater than 0.")
7777
self._max_turns = max_turns
7878
self._current_turn = 0
7979
self._message_factory = message_factory

0 commit comments

Comments
 (0)