abelenguerv's picture
First simple langgraph
6756386
Raw
History Blame Contribute Delete
575 Bytes
import random
from typing import Literal
from langgraph.types import Command
from states.state import State
def decide_1(state: State) -> Command[Literal["node_2", "node_3"]]:
# --- Decide 1: Random Decision ---
if random.choice([True, False]):
next_node = "node_2"
next_state = "Node 2: Decision made."
else:
next_node = "node_3"
next_state = "Node 3: Decision made."
state.set_graph_state("decide_1", next_state)
state.log_node_end("decide_1")
return Command(
goto=next_node,
update=state,
)