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=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
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 |
|