a_initiate_swarm_chat
autogen.a_initiate_swarm_chat async
#
a_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 asynchronously
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
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 |
|