Skip to main content

agentchat.contrib.agent_optimizer

execute_func

def execute_func(name, packages, code, **args)

The wrapper for generated functions.

AgentOptimizer

class AgentOptimizer()

Base class for optimizing AutoGen agents. Specifically, it is used to optimize the functions used in the agent. More information could be found in the following paper: https://arxiv.org/abs/2402.11359.

__init__

def __init__(max_actions_per_step: int,
llm_config: dict,
optimizer_model: Optional[str] = "gpt-4-1106-preview")

(These APIs are experimental and may change in the future.)

Arguments:

  • max_actions_per_step int - the maximum number of actions that the optimizer can take in one step.
  • llm_config dict - llm inference configuration. Please refer to OpenAIWrapper.create for available options. When using OpenAI or Azure OpenAI endpoints, please specify a non-empty 'model' either in llm_config or in each config of 'config_list' in llm_config.
  • optimizer_model - the model used for the optimizer.

record_one_conversation

def record_one_conversation(conversation_history: List[Dict],
is_satisfied: bool = None)

record one conversation history.

Arguments:

  • conversation_history List[Dict] - the chat messages of the conversation.
  • is_satisfied bool - whether the user is satisfied with the solution. If it is none, the user will be asked to input the satisfaction.

step

def step()

One step of training. It will return register_for_llm and register_for_executor at each iteration, which are subsequently utilized to update the assistant and executor agents, respectively. See example: https://github.com/microsoft/autogen/blob/main/notebook/agentchat_agentoptimizer.ipynb

reset_optimizer

def reset_optimizer()

reset the optimizer.