math_user_proxy_agent
autogen.agentchat.contrib.math_user_proxy_agent.MathUserProxyAgent
MathUserProxyAgent
(Experimental) A MathChat agent that can handle math problems.
Parameters:Name | Description |
---|---|
name | name of the agent Type: str | None Default: ‘MathChatAgent’ |
is_termination_msg | a function that takes a message in the form of a dictionary and returns a boolean value indicating if this received message is a termination message. The dict can contain the following keys: “content”, “role”, “name”, “function_call”. Type: Callable[[dict], bool] | None Default: <function _is_termination_msg_mathchat> |
human_input_mode | whether to ask for human inputs every time a message is received. Possible values are “ALWAYS”, “TERMINATE”, “NEVER”. (1) When “ALWAYS”, the agent prompts for human input every time a message is received. Under this mode, the conversation stops when the human input is “exit”, or when is_termination_msg is True and there is no human input. (2) When “TERMINATE”, the agent only prompts for human input only when a termination message is received or the number of auto reply reaches the max_consecutive_auto_reply. (3) (Default) When “NEVER”, the agent will never prompt for human input. Under this mode, the conversation stops when the number of auto reply reaches the max_consecutive_auto_reply or when is_termination_msg is True. Type: Literal['ALWAYS', 'NEVER', 'TERMINATE'] Default: ‘NEVER’ |
default_auto_reply | the default auto reply message when no code execution or llm based reply is generated. Type: dict | str | None Default: ‘Continue. Please keep solving the problem until you need to query. (If you get to the answer, put it in \boxed{}.)’ |
max_invalid_q_per_step=3 | |
**kwargs | other kwargs in UserProxyAgent. |
Class Attributes
DEFAULT_REPLY
MAX_CONSECUTIVE_AUTO_REPLY
Static Methods
message_generator
Generate a prompt for the assistant agent with the given problem and prompt.
Parameters:Name | Description |
---|---|
sender | the sender of the message. |
recipient | the recipient of the message. |
context | a dictionary with the following fields: problem (str): the problem to be solved. prompt_type (str, Optional): the type of the prompt. Possible values are “default”, “python”, “wolfram”. (1) “default”: the prompt that allows the agent to choose between 3 ways to solve a problem: 1. write a python program to solve it directly. 2. solve it directly without python. 3. solve it step by step with python. (2) “python”: a simplified prompt from the third way of the “default” prompt, that asks the assistant to solve the problem step by step with python. (3) “two_tools”: a simplified prompt similar to the “python” prompt, but allows the model to choose between Python and Wolfram Alpha to solve the problem. customized_prompt (str, Optional): a customized prompt to be used. If it is not None, the prompt_type will be ignored. |
Instance Methods
execute_one_python_code
Execute python code blocks.
Previous python code will be saved and executed together with the new code. the “print” function will also be added to the last line of the code if needed
Parameters:Name | Description |
---|---|
pycode |
execute_one_wolfram_query
Run one wolfram query and return the output.
Parameters:Name | Description |
---|---|
query | string of the query. Type: str |