initiate_swarm_chat
autogen.initiate_swarm_chat #
initiate_swarm_chat(initial_agent, messages, agents, user_agent=None, swarm_manager_args=None, max_rounds=20, context_variables=None, after_work=AfterWork(TERMINATE), exclude_transit_message=True)
Initialize and run a swarm chat
PARAMETER | DESCRIPTION |
---|---|
initial_agent | The first receiving agent of the conversation. TYPE: |
messages | Initial message(s). |
agents | list of swarm agents. TYPE: |
user_agent | Optional user proxy agent for falling back to. TYPE: |
swarm_manager_args | Optional group chat manager arguments used to establish the swarm's groupchat manager, required when AfterWorkOption.SWARM_MANAGER is used. |
max_rounds | Maximum number of conversation rounds. TYPE: |
context_variables | Starting context variables. |
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 AfterWork instance (which is a dataclass accepting a ConversableAgent, 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 ConversableAgent (by reference or string name). TYPE: |
exclude_transit_message | all registered handoff function call and responses messages will be removed from message list before calling an LLM. Note: only with transition functions added with TYPE: |
Returns: ChatResult: Conversations chat history. Dict[str, Any]: Updated Context variables. ConversableAgent: Last speaker.
Source code in autogen/agentchat/contrib/swarm_agent.py
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 |
|