autogen
autogen.initiate_swarm_chat
initiate_swarm_chat
Initialize and run a swarm chat
Parameters:Name | Description |
---|---|
initial_agent | The first receiving agent of the conversation. Type: SwarmAgent |
messages | Initial message(s). Type: list[dict[str, typing.Any]] | str |
agents | List of swarm agents. Type: list['SwarmAgent'] |
user_agent | Optional user proxy agent for falling back to. Type: autogen.UserProxyAgent | None Default: None |
max_rounds | Maximum number of conversation rounds. Type: int Default: 20 |
context_variables | Starting context variables. Type: dict[str, typing.Any] | None Default: None |
after_work | Method to handle conversation continuation when an agent doesn’t select the next agent. If no agent is selected and no tool calls are output, we will use this method to determine the next agent. Must be a AFTER_WORK instance (which is a dataclass accepting a SwarmAgent, AfterWorkOption, A str (of the AfterWorkOption)) or a callable. AfterWorkOption: - TERMINATE (Default): Terminate the conversation. - REVERT_TO_USER : Revert to the user agent if a user agent is provided. If not provided, terminate the conversation. - STAY : Stay with the last speaker. Callable: A custom function that takes the current agent, messages, and groupchat as arguments and returns an AfterWorkOption or a SwarmAgent (by reference or string name). python def custom_afterwork_func(last_speaker: SwarmAgent, messages: List[Dict[str, Any]], groupchat: GroupChat) -> Union[AfterWorkOption, SwarmAgent, str]: Type: autogen.AfterWorkOption | Callable | None = AFTER_WORK(agent Default: <AfterWorkOption.TERMINATE |
Type | Description |
---|---|
tuple[autogen.ChatResult, dict[str, typing.Any], 'SwarmAgent'] | ChatResult: Conversations chat history. Dict[str, Any]: Updated Context variables. SwarmAgent: Last speaker. |