This commit is contained in:
vbarda
2024-12-04 16:50:56 -05:00
parent 89a739e12b
commit d52bb911a4
+8 -2
View File
@@ -103,8 +103,10 @@
"class State(TypedDict):\n",
" foo: str\n",
"\n",
"\n",
"# Define the nodes\n",
"\n",
"\n",
"def node_a(state: State) -> GraphCommand[Literal[\"node_b\", \"node_c\"]]:\n",
" print(\"Called A\")\n",
" value = random.choice([\"a\", \"b\"])\n",
@@ -119,16 +121,19 @@
" # this is the state update\n",
" update={\"foo\": value},\n",
" # this is a replacement for an edge\n",
" goto=goto\n",
" goto=goto,\n",
" )\n",
"\n",
"\n",
"# Nodes B and C are unchanged\n",
"\n",
"\n",
"def node_b(state: State):\n",
" print(\"Called B\")\n",
" # graph command can also be used \n",
" # graph command can also be used\n",
" return {\"foo\": state[\"foo\"] + \"b\"}\n",
"\n",
"\n",
"def node_c(state: State):\n",
" print(\"Called C\")\n",
" return {\"foo\": state[\"foo\"] + \"c\"}"
@@ -188,6 +193,7 @@
],
"source": [
"from IPython.display import display, Image\n",
"\n",
"display(Image(graph.get_graph().draw_mermaid_png()))"
]
},