AssistantAgent

AssistantAgent(
    name: str,
    system_message: str | None = 'You are a helpful AI assistant.\nSolve tasks using your coding and language skills.\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\n    1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\n    2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can\'t modify your code. So do not suggest incomplete code which requires users to modify. Don\'t use a code block if it\'s not intended to be executed by the user.\nIf you want the user to save the code in a file before executing it, put # filename: <filename> inside the code block as the first line. Don\'t include multiple code blocks in one response. Do not ask users to copy and paste the result. Instead, use \'print\' function for the output when relevant. Check the execution result returned by the user.\nIf the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can\'t be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.\nWhen you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible.\nReply "TERMINATE" in the end when everything is done.\n    ',
    llm_config: dict | Literal[False] | None = None,
    is_termination_msg: Callable[[dict], bool] | None = None,
    max_consecutive_auto_reply: int | None = None,
    human_input_mode: Literal['ALWAYS', 'NEVER', 'TERMINATE'] = 'NEVER',
    description: str | None = None,
    **kwargs
)

(In preview) Assistant agent, designed to solve a task with LLM.

AssistantAgent is a subclass of ConversableAgent configured with a default system message. The default system message is designed to solve a task with LLM, including suggesting python code blocks and debugging. human_input_mode is default to “NEVER” and code_execution_config is default to False. This agent doesn’t execute code by default, and expects the user to execute the code.

Parameters:
NameDescription
nameagent name.

Type: str
system_messagesystem message for the ChatCompletion inference.

Please override this attribute if you want to reprogram the agent.

Type: str | None

Default: ‘You are a helpful AI assistant.\nSolve tasks using your coding and language skills.\nIn the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the user to execute.\n 1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself.\n 2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly.\nSolve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill.\nWhen using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can’t modify your code. So do not suggest incomplete code which requires users to modify. Don’t use a code block if it’s not intended to be executed by the user.\nIf you want the user to save the code in a file before executing it, put # filename
llm_configllm inference configuration.

Please refer to OpenAIWrapper.create for available options.

Type: dict | Literal[False] | None

Default: None
is_termination_msga 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: None
max_consecutive_auto_replythe maximum number of consecutive auto replies.

default to None (no limit provided, class attribute MAX_CONSECUTIVE_AUTO_REPLY will be used as the limit in this case).

The limit only plays a role when human_input_mode is not “ALWAYS”.

Type: int | None

Default: None
human_input_modeType: Literal['ALWAYS', 'NEVER', 'TERMINATE']

Default: ‘NEVER’
descriptionType: str | None

Default: None
**kwargsPlease refer to other kwargs in ConversableAgent.

Class Attributes

DEFAULT_DESCRIPTION



DEFAULT_SYSTEM_MESSAGE