agentchat.contrib.agent_optimizer
execute_func
def execute_func(name, packages, code, **args)
生成函数的包装器。
AgentOptimizer
class AgentOptimizer()
用于优化 AutoGen 代理的基类。具体来说,它用于优化代理中使用的函数。 更多信息可以在以下论文中找到: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")
(这些 API 是实验性的,可能会在将来发生变化。)
参数:
max_actions_per_step
int - 优化器在一步中可以执行的最大动作数。llm_config
dict - llm 推理配置。 有关可用选项,请参阅 OpenAIWrapper.create。 当使用 OpenAI 或 Azure OpenAI 端点时,请在llm_config
中或在llm_config
的 'config_list' 中的每个配置中指定一个非空的 'model'。optimizer_model
- 优化器使用的模型。
record_one_conversation
def record_one_conversation(conversation_history: List[Dict],
is_satisfied: bool = None)
记录一次对话历史。
参数:
conversation_history
List[Dict] - 对话的聊天消息。is_satisfied
bool - 用户是否对解决方案满意。如果为 None,则会要求用户输入满意度。
step
def step()
训练的一步。它将在每次迭代时返回 register_for_llm 和 register_for_executor, 这些值随后用于更新助手和执行器代理。参见示例:https://github.com/microsoft/autogen/blob/main/notebook/agentchat_agentoptimizer.ipynb
reset_optimizer
def reset_optimizer()
重置优化器。