Skip to content

Commit

Permalink
docs: update branching how-to notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
vbarda committed Oct 24, 2024
1 parent 83238f5 commit a8dee89
Showing 1 changed file with 39 additions and 21 deletions.
60 changes: 39 additions & 21 deletions docs/docs/how-tos/branching.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"id": "09372b8b-edea-4b9d-9ec3-3d93ce1ba819",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -132,7 +132,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "66f52a20",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -163,7 +163,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "38846b01",
"metadata": {},
"outputs": [
Expand All @@ -183,7 +183,7 @@
"{'aggregate': [\"I'm A\", \"I'm B\", \"I'm C\", \"I'm D\"]}"
]
},
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -220,7 +220,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"id": "259a7704-5aa0-4e4c-aeef-cca04e8be0ff",
"metadata": {},
"outputs": [],
Expand All @@ -238,6 +238,15 @@
" aggregate: Annotated[list, operator.add]\n",
"\n",
"\n",
"class ReturnNodeValue:\n",
" def __init__(self, node_secret: str):\n",
" self._value = node_secret\n",
"\n",
" def __call__(self, state: State) -> Any:\n",
" print(f\"Adding {self._value} to {state['aggregate']}\")\n",
" return {\"aggregate\": [self._value]}\n",
"\n",
"\n",
"builder = StateGraph(State)\n",
"builder.add_node(\"a\", ReturnNodeValue(\"I'm A\"))\n",
"builder.add_edge(START, \"a\")\n",
Expand All @@ -255,7 +264,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"id": "83320227-8ab3-44c0-b6cf-064a7a425b9f",
"metadata": {},
"outputs": [
Expand All @@ -278,7 +287,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"id": "3f971fa3-29e4-466f-a85e-2863bfecf7fe",
"metadata": {},
"outputs": [
Expand All @@ -299,7 +308,7 @@
"{'aggregate': [\"I'm A\", \"I'm B\", \"I'm C\", \"I'm B2\", \"I'm D\"]}"
]
},
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -322,7 +331,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"id": "95f5e026",
"metadata": {},
"outputs": [],
Expand All @@ -341,6 +350,15 @@
" which: str\n",
"\n",
"\n",
"class ReturnNodeValue:\n",
" def __init__(self, node_secret: str):\n",
" self._value = node_secret\n",
"\n",
" def __call__(self, state: State) -> Any:\n",
" print(f\"Adding {self._value} to {state['aggregate']}\")\n",
" return {\"aggregate\": [self._value]}\n",
"\n",
"\n",
"builder = StateGraph(State)\n",
"builder.add_node(\"a\", ReturnNodeValue(\"I'm A\"))\n",
"builder.add_edge(START, \"a\")\n",
Expand Down Expand Up @@ -372,7 +390,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"id": "1d0e6c56",
"metadata": {},
"outputs": [
Expand All @@ -395,7 +413,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"id": "7134f652",
"metadata": {},
"outputs": [
Expand All @@ -415,7 +433,7 @@
"{'aggregate': [\"I'm A\", \"I'm B\", \"I'm C\", \"I'm E\"], 'which': 'bc'}"
]
},
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -426,7 +444,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 11,
"id": "b130e694",
"metadata": {},
"outputs": [
Expand All @@ -446,7 +464,7 @@
"{'aggregate': [\"I'm A\", \"I'm C\", \"I'm D\", \"I'm E\"], 'which': 'cd'}"
]
},
"execution_count": 12,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -471,7 +489,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 12,
"id": "836bc12d",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -564,7 +582,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 13,
"id": "932c497e",
"metadata": {},
"outputs": [
Expand All @@ -587,7 +605,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 14,
"id": "933b3afd",
"metadata": {},
"outputs": [
Expand All @@ -608,7 +626,7 @@
" 'which': 'bc'}"
]
},
"execution_count": 15,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -619,7 +637,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 15,
"id": "e30531bf",
"metadata": {},
"outputs": [
Expand All @@ -640,7 +658,7 @@
" 'which': 'cd'}"
]
},
"execution_count": 16,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -666,7 +684,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down

0 comments on commit a8dee89

Please sign in to comment.