Help Solve ""Must write to at least one of []"" , Trying to build Customer Support Agent #1650
Replies: 1 comment
-
Stack Trace I am getting : ERROR:root:Traceback (most recent call last): |
Beta Was this translation helpful? Give feedback.
-
Hey,
I was trying to build customer support agent on a different use case for production , hosted on FAST API, I am stucked with the error " Must write to at least one of [] ". I am Invoking graph wit '''result = abot.graph_compiler.invoke({"messages": ("user",messages)},thread)'''
My Graph is similar to :
builder = StateGraph(State)
#Adding Get Order Info Node
builder.add_node("fetch_user_info", self.user_info)
builder.set_entry_point("fetch_user_info")
#Adding Delivery Preference Asistant
builder.add_node(
"enter_delivery_preference",
create_entry_node("Delivery Preference Update Assistant", "delivery_preference"),
)
builder.add_node("delivery_preference", Assistant(delivery_preference_runnable))
builder.add_edge("enter_delivery_preference", "delivery_preference")
builder.add_node(
"delivery_preference_sensitive_tools",
create_tool_node_with_fallback(delivery_preference_sensitive_tools),
)
builder.add_node(
"delivery_preference_safe_tools",
create_tool_node_with_fallback(delivery_preference_safe_tools),
)
builder.add_edge("delivery_preference_sensitive_tools", "delivery_preference")
builder.add_edge("delivery_preference_safe_tools", "delivery_preference")
builder.add_conditional_edges("delivery_preference", self.route_delivery_preference)
builder.add_node("leave_skill", self.pop_dialog_state)
builder.add_edge("leave_skill", "primary_assistant")
#Adding Update Buyer Info Assistant
builder.add_node(
"enter_update_buyer_info",
create_entry_node("Update Buyer Info Assistant", "update_buyer_info"),
)
builder.add_node("update_buyer_info", Assistant(update_buyer_info_runnable))
builder.add_edge("enter_update_buyer_info", "update_buyer_info")
builder.add_node(
"update_buyer_info_safe_tools",
create_tool_node_with_fallback(update_buyer_info_safe_tools),
)
builder.add_node(
"update_buyer_info_sensitive_tools",
create_tool_node_with_fallback(update_buyer_info_sensitive_tools),
)
builder.add_edge("update_buyer_info_sensitive_tools", "update_buyer_info")
builder.add_edge("update_buyer_info_safe_tools", "update_buyer_info")
builder.add_conditional_edges("update_buyer_info", self.route_update_buyer_info)
Create Escalation assistant
builder.add_node(
"enter_create_escalation", create_entry_node("Escalation Creation Agent", "create_escalation")
)
builder.add_node("create_escalation", Assistant(create_escalation_runnable))
builder.add_edge("enter_create_escalation", "create_escalation")
builder.add_node(
"create_escalation_safe_tools",
create_tool_node_with_fallback(create_escalation_safe_tools),
)
builder.add_node(
"create_escalation_sensitive_tools",
create_tool_node_with_fallback(create_escalation_sensitive_tools),
)
builder.add_edge("create_escalation_sensitive_tools", "create_escalation")
builder.add_edge("create_escalation_safe_tools", "create_escalation")
builder.add_conditional_edges("create_escalation", self.route_create_escalation)
Cancellation assistant
builder.add_node(
"enter_cancel_order",
create_entry_node("Cancel Order Assistant", "cancel_order"),
)
builder.add_node("cancel_order", Assistant(cancel_order_runnable))
builder.add_edge("enter_cancel_order", "cancel_order")
builder.add_node(
"cancel_order_safe_tools",
create_tool_node_with_fallback(cancel_order_safe_tools),
)
builder.add_node(
"cancel_order_sensitive_tools",
create_tool_node_with_fallback(cancel_order_sensitive_tools),
)
builder.add_edge("cancel_order_sensitive_tools", "cancel_order")
builder.add_edge("cancel_order_safe_tools", "cancel_order")
builder.add_conditional_edges("cancel_order", self.route_cancel_order)
Primary assistant
builder.add_node("primary_assistant", Assistant(assistant_runnable))
builder.add_node(
"primary_assistant_tools", create_tool_node_with_fallback(primary_assistant_tools)
)
The assistant can route to one of the delegated assistants,
directly use a tool, or directly respond to the user
builder.add_conditional_edges(
"primary_assistant",
self.route_primary_assistant,
{
"enter_delivery_preference": "enter_delivery_preference",
"enter_update_buyer_info": "enter_update_buyer_info",
"enter_create_escalation": "enter_create_escalation",
"enter_cancel_order": "enter_cancel_order",
"primary_assistant_tools": "primary_assistant_tools",
END: END,
},
)
builder.add_edge("primary_assistant_tools", "primary_assistant")
builder.add_conditional_edges("fetch_user_info", self.route_to_workflow)
Compile graph
memory = SqliteSaver.from_conn_string(":memory:")
part_4_graph = builder.compile(
checkpointer=memory,
# Let the user approve or deny the use of sensitive tools
interrupt_before=[
"delivery_preference_sensitive_tools",
"update_buyer_info_sensitive_tools",
"create_escalation_sensitive_tools",
"cancel_order_sensitive_tools",
],
)
self.graph_compiler=part_4_graph
Please help!
Beta Was this translation helpful? Give feedback.
All reactions