-
Notifications
You must be signed in to change notification settings - Fork 206
Open
Description
More of a suggestions than an issue, but the code below does exactly the same as yours, just with one less level of indirection. Is there any particular reason you went with the more complex implementation? It seems to me like it makes the learning curve harder than it needs to be at this step of the tutorial.
def decide_next_node(state:AgentState) -> AgentState:
"""This node will select the next node of the graph"""
if state["operation"] == "+":
return "add_node"
elif state["operation"] == "-":
return "subtract_node"
graph = StateGraph(AgentState)
graph.add_node("add_node", adder)
graph.add_node("subtract_node", subtractor)
graph.add_node("router", lambda state:state) # passthrough function
graph.add_edge(START, "router")
graph.add_conditional_edges(
"router",
decide_next_node,
["add_node", "subtract_node"]
)
graph.add_edge("add_node", END)
graph.add_edge("subtract_node", END)
app = graph.compile()Metadata
Metadata
Assignees
Labels
No labels