我在使用autogen
库创建群聊时遇到了一个与allowed_speaker_transitions_dict
相关的错误。以下是我代码的简化版本:
# 定义数据获取工具。
data_search_agent = AssistantAgent(
name="assistant",
model_client=az_model_client,
tools=[
get_customer_details_by_customerid,
get_customer_bill_details_by_customerid,
get_customer_call_center_conversations_by_customerid,
get_customer_email_conversations_by_customerid,
get_customer_order_detail_by_customerid
],
system_message="system message",
)
# 定义账单检查代理。
bill_inspection_agent = AssistantAgent(
name="billing_assistant",
model_client=az_model_client_o1,
system_message="system message",
)
# 定义监督代理。
supervisor_agent = AssistantAgent(
name="supervison_assistant",
model_client=az_model_client,
system_message="您的工作是查看查询并要求适当的代理开始工作。您是监督者,必须确保工作正确完成。",
)
user_proxy = autogen.ConversableAgent(
name="Admin",
system_message="分配任务,并发送",
code_execution_config=False,
llm_config=llm_config,
human_input_mode="ALWAYS",
)
groupchat = autogen.GroupChat(
agents=[user_proxy, data_search_agent, supervisor_agent, bill_inspection_agent],
messages=[],
max_round=10,
)
manager = autogen.GroupChatManager(
groupchat=groupchat, model_client=az_model_client
)
这导致了以下错误:
ValueError: allowed_speaker_transitions_dict has values that are not lists of Agents.
完整的错误跟踪:
Traceback (most recent call last):
File "agents.py", line 652, in <module>
groupchat = autogen.GroupChat(
File "<string>", line 21, in __init__
File "groupchat.py", line 220, in __post_init__
check_graph_validity(
File "graph_utils.py", line 52, in check_graph_validity
raise ValueError("allowed_speaker_transitions_dict has values that are not lists of Agents.")
ValueError: allowed_speaker_transitions_dict has values that are not lists of Agents.
回答:
群聊不允许使用带工具的代理,我们可以使用SelectorGroupChat或其他对话模式来适应带工具/函数调用的代理。