GroupToolExecutor
Instance Attributes
chat_messages
A dictionary of conversations from agent to list of messages.
code_executor
The code executor used by this agent. Returns None if code execution is disabled.
description
Get the description of the agent.
function_map
Return the function map.
name
Get the name of the agent.
system_message
Return the system message.
tools
Get the agent’s tools (registered for LLM) Note this is a copy of the tools list, use add_tool and remove_tool to modify the tools list.
use_docker
Bool value of whether to use docker to execute the code, or str value of the docker image name to use, or None when code execution is disabled.
Instance Methods
a_check_termination_and_human_reply
This method checks for conditions that require the conversation to be terminated, such as reaching a maximum number of consecutive auto-replies or encountering a termination message. Additionally, it prompts for and processes human input based on the configured human input mode, which can be ‘ALWAYS’, ‘NEVER’, or ‘TERMINATE’. The method also manages the consecutive auto-reply counter for the conversation and prints relevant messages based on the human input received.
Parameters:
Returns:
a_execute_function
Override this function to modify the way async functions and tools are executed.
Parameters:
Returns:
a_generate_function_call_reply
”function_call” replaced by “tool_calls” as of OpenAI API v1.1.0 See https://platform.openai.com/docs/api-reference/chat/create#chat-create-functions Parameters:
a_generate_init_message
If message is None, input() will be called to get the initial message.
Parameters:
Returns:
a_generate_oai_reply
a_generate_reply
Either messages or sender must be provided.
Register a reply_func with
None as one trigger for it to be activated when messages is non-empty and sender is None.Use registered auto reply functions to generate replies.
By default, the following functions are checked in order:
1. check_termination_and_human_reply 2. generate_function_call_reply 3. generate_tool_calls_reply 4. generate_code_execution_reply 5. generate_oai_reply Every function returns a tuple (final, reply).
When a function returns final=False, the next function will be checked.
So by default, termination and human reply will be checked first.
If not terminating and human reply is skipped, execute function or code and return the result.
AI replies are generated only when no code execution is performed.
Parameters:
Returns:
a_generate_tool_calls_reply
a_get_human_input
Override this method to customize the way to get human input.
Parameters:
Returns:
a_initiate_chat
Reset the consecutive auto reply counter.
If
clear_history is True, the chat history with the recipient agent will be cleared.a_generate_init_message is called to generate the initial message for the agent.Parameters:
Returns:
a_receive
Once a message is received, this function sends a reply to the sender or stop.
The reply can be generated automatically or entered manually by a human.
Parameters:
a_send
Parameters:
a_sequential_run
Parameters:
Returns:
can_execute_function
chat_messages_for_summary
check_termination_and_human_reply
This method checks for conditions that require the conversation to be terminated, such as reaching a maximum number of consecutive auto-replies or encountering a termination message. Additionally, it prompts for and processes human input based on the configured human input mode, which can be ‘ALWAYS’, ‘NEVER’, or ‘TERMINATE’. The method also manages the consecutive auto-reply counter for the conversation and prints relevant messages based on the human input received.
Parameters:
Returns:
clear_history
Parameters:
clear_next_target
execute_code_blocks
execute_function
Override this function to modify the way to execute function and tool calls.
Parameters:
Returns:
generate_code_execution_reply
generate_function_call_reply
”function_call” replaced by “tool_calls” as of OpenAI API v1.1.0 See https://platform.openai.com/docs/api-reference/chat/create#chat-create-functions Parameters:
generate_init_message
If message is None, input() will be called to get the initial message.
Parameters:
Returns:
generate_oai_reply
generate_reply
Either messages or sender must be provided.
Register a reply_func with
None as one trigger for it to be activated when messages is non-empty and sender is None.Use registered auto reply functions to generate replies.
By default, the following functions are checked in order:
1. check_termination_and_human_reply 2. generate_function_call_reply (deprecated in favor of tool_calls) 3. generate_tool_calls_reply 4. generate_code_execution_reply 5. generate_oai_reply Every function returns a tuple (final, reply).
When a function returns final=False, the next function will be checked.
So by default, termination and human reply will be checked first.
If not terminating and human reply is skipped, execute function or code and return the result.
AI replies are generated only when no code execution is performed.
Parameters:
Returns:
generate_tool_calls_reply
get_actual_usage
get_chat_results
get_human_input
Override this method to customize the way to get human input.
Parameters:
Returns:
get_next_target
get_total_usage
has_next_target
initiate_chat
Reset the consecutive auto reply counter.
If
clear_history is True, the chat history with the recipient agent will be cleared.Parameters:
Returns:
initiate_chats
Parameters:
Returns:
last_message
Parameters:
Returns:
max_consecutive_auto_reply
print_usage_summary
process_all_messages_before_reply
process_last_received_message
receive
Once a message is received, this function sends a reply to the sender or stop.
The reply can be generated automatically or entered manually by a human.
Parameters:
register_agents_functions
register_for_execution
It’s return value is used to decorate a function to be registered to the agent.
Parameters:
Returns:
register_for_llm
It’s return value is used to decorate a function to be registered to the agent. The function uses type hints to specify the arguments and return type. The function name is used as the default name for the function, but a custom name can be provided. The function description is used to describe the function in the agent’s configuration.
Parameters:
Returns:
register_function
Parameters:
register_handoff
Parameters:
register_handoffs
Parameters:
register_hook
Registered hooks are kept in lists (one per hookable method), and are called in their order of registration.
Parameters:
register_model_client
Parameters:
register_nested_chats
Parameters:
register_reply
The reply function will be called when the trigger matches the sender.
The function registered later will be checked earlier by default.
To change the order, set the position to a positive integer.
Both sync and async reply functions can be registered. The sync reply function will be triggered from both sync and async chats. However, an async reply function will only be triggered from async chats (initiated with
ConversableAgent.a_initiate_chat). If an async reply function is registered
and a chat is initialized with a sync function, ignore_async_in_sync_chat determines the behaviour as follows: if
ignore_async_in_sync_chat is set to False (default value), an exception will be raised, and
if ignore_async_in_sync_chat is set to True, the reply function will be ignored.Parameters:
remove_tool_for_llm
replace_reply_func
Parameters:
reset
reset_consecutive_auto_reply_counter
run_code
Override this function to modify the way to run the code.
Parameters:
Returns:
send
Parameters:
sequential_run
Parameters:
Returns:
set_next_target
set_ui_tools
Parameters:
stop_reply_at_receive
unset_ui_tools
Parameters:
update_agent_state_before_reply
Primarily used to update context variables.
Will, potentially, modify the messages. Parameters:
update_function_signature
Parameters:
update_max_consecutive_auto_reply
Parameters:
update_system_message
Parameters:
update_tool_signature
Parameters: