File size: 575 Bytes
6756386
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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,
    )