Spaces:
Sleeping
Sleeping
File size: 1,008 Bytes
bf6dbfa 0643073 bf6dbfa 0643073 bf6dbfa 0643073 bf6dbfa | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | from agent.state import AgentState
def route_intent(state: AgentState) -> str:
"""
Router node that directs the workflow based on the detected intent.
It returns the name of the next node to execute.
"""
intent = state.get("detected_intent")
has_partial_lead = (
state.get("user_name") is not None or
state.get("user_email") is not None or
state.get("creator_platform") is not None
) and not state.get("lead_ready")
if intent == "HIGH_INTENT_LEAD" or has_partial_lead:
return "process_lead"
elif intent in ["PRODUCT_QUERY", "PRICING_QUERY"]:
return "retrieve_knowledge"
elif intent == "GREETING":
return "handle_greeting"
else:
return "handle_unknown"
def route_after_lead(state: AgentState) -> str:
"""
Router node after process_lead to decide whether to execute the tool or stop.
"""
if state.get("lead_ready"):
return "execute_tool"
else:
return "__end__"
|