Skip to content

Commit b5fb522

Browse files
committed
Reorder graph building
1 parent c0dc8a6 commit b5fb522

File tree

1 file changed

+54
-37
lines changed

1 file changed

+54
-37
lines changed

18.langgraph-basics.ipynb

+54-37
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"cells": [
1717
{
1818
"cell_type": "code",
19-
"execution_count": 1,
19+
"execution_count": null,
2020
"metadata": {
2121
"id": "TT_sLhpoqXaf"
2222
},
@@ -56,7 +56,7 @@
5656
"metadata": {
5757
"id": "Aj8xGG_EwNOk"
5858
},
59-
"execution_count": 2,
59+
"execution_count": null,
6060
"outputs": []
6161
},
6262
{
@@ -204,7 +204,7 @@
204204
"metadata": {
205205
"id": "eqC9CyQo_-ls"
206206
},
207-
"execution_count": 3,
207+
"execution_count": null,
208208
"outputs": []
209209
},
210210
{
@@ -224,7 +224,7 @@
224224
"id": "Sgvs5qBlPbuX",
225225
"outputId": "fdbbbaee-def8-4a59-b080-4760eb724cb4"
226226
},
227-
"execution_count": 4,
227+
"execution_count": null,
228228
"outputs": [
229229
{
230230
"output_type": "execute_result",
@@ -250,7 +250,7 @@
250250
"id": "6hqpho6ua2ae",
251251
"outputId": "ef92ef67-a95a-4886-b7f8-6912da8b4786"
252252
},
253-
"execution_count": 5,
253+
"execution_count": null,
254254
"outputs": [
255255
{
256256
"output_type": "execute_result",
@@ -323,7 +323,7 @@
323323
"metadata": {
324324
"id": "UBPrIIx_dnJ8"
325325
},
326-
"execution_count": 6,
326+
"execution_count": null,
327327
"outputs": []
328328
},
329329
{
@@ -335,7 +335,7 @@
335335
"metadata": {
336336
"id": "CbWPSzdmLUpG"
337337
},
338-
"execution_count": 7,
338+
"execution_count": null,
339339
"outputs": []
340340
},
341341
{
@@ -366,7 +366,7 @@
366366
"metadata": {
367367
"id": "jdv1LiyDqFJ-"
368368
},
369-
"execution_count": 8,
369+
"execution_count": null,
370370
"outputs": []
371371
},
372372
{
@@ -388,12 +388,8 @@
388388
")\n",
389389
"\n",
390390
"\n",
391-
"def should_continue(state: AppState) -> Literal[\"tools\", END]:\n",
392-
" messages = state[\"messages\"]\n",
393-
" last_message = messages[-1]\n",
394-
" if last_message.tool_calls:\n",
395-
" return \"tools\"\n",
396-
" return END\n",
391+
"def update_habits(state: AppState):\n",
392+
" return {\"habits\": list_habits()}\n",
397393
"\n",
398394
"\n",
399395
"def call_model(state: AppState):\n",
@@ -408,16 +404,37 @@
408404
" return {\"messages\": [response]}\n",
409405
"\n",
410406
"\n",
411-
"def update_habits(state: AppState):\n",
412-
" return {\"habits\": list_habits()}\n",
413-
"\n",
414-
"\n",
415407
"tool_node = ToolNode(tools)"
416408
],
417409
"metadata": {
418410
"id": "gargdh3SdrEf"
419411
},
420-
"execution_count": 9,
412+
"execution_count": null,
413+
"outputs": []
414+
},
415+
{
416+
"cell_type": "markdown",
417+
"source": [
418+
"## Edges"
419+
],
420+
"metadata": {
421+
"id": "OK5OZ69DJfxz"
422+
}
423+
},
424+
{
425+
"cell_type": "code",
426+
"source": [
427+
"def should_continue(state: AppState) -> Literal[\"tools\", END]:\n",
428+
" messages = state[\"messages\"]\n",
429+
" last_message = messages[-1]\n",
430+
" if last_message.tool_calls:\n",
431+
" return \"tools\"\n",
432+
" return END"
433+
],
434+
"metadata": {
435+
"id": "nA2IBAs1Jg2v"
436+
},
437+
"execution_count": null,
421438
"outputs": []
422439
},
423440
{
@@ -450,7 +467,7 @@
450467
"metadata": {
451468
"id": "ENYse6ymdueN"
452469
},
453-
"execution_count": 10,
470+
"execution_count": null,
454471
"outputs": []
455472
},
456473
{
@@ -465,7 +482,7 @@
465482
"id": "CfrH4h2m3uJE",
466483
"outputId": "e514049b-7ef9-4aa3-e6ee-539ee758d74e"
467484
},
468-
"execution_count": 11,
485+
"execution_count": null,
469486
"outputs": [
470487
{
471488
"output_type": "execute_result",
@@ -493,7 +510,7 @@
493510
"id": "iQGQMuwO4hU1",
494511
"outputId": "d809fd1f-4e97-4607-8962-fd71f801ae02"
495512
},
496-
"execution_count": 12,
513+
"execution_count": null,
497514
"outputs": [
498515
{
499516
"output_type": "execute_result",
@@ -521,7 +538,7 @@
521538
"id": "-xgnCykJ40J5",
522539
"outputId": "38ca2ebf-9621-49d4-a935-55c06d3a8af9"
523540
},
524-
"execution_count": 13,
541+
"execution_count": null,
525542
"outputs": [
526543
{
527544
"output_type": "execute_result",
@@ -554,7 +571,7 @@
554571
"metadata": {
555572
"id": "OAatzQOjd8hY"
556573
},
557-
"execution_count": 14,
574+
"execution_count": null,
558575
"outputs": []
559576
},
560577
{
@@ -570,7 +587,7 @@
570587
"id": "UWOeqN7kPlgB",
571588
"outputId": "cda703aa-9902-4652-93df-d1862f9fd78e"
572589
},
573-
"execution_count": 15,
590+
"execution_count": null,
574591
"outputs": [
575592
{
576593
"output_type": "display_data",
@@ -606,7 +623,7 @@
606623
"metadata": {
607624
"id": "WW9N4QBcIOGB"
608625
},
609-
"execution_count": 16,
626+
"execution_count": null,
610627
"outputs": []
611628
},
612629
{
@@ -621,7 +638,7 @@
621638
"id": "kBKSyHSQwVnW",
622639
"outputId": "82e90362-f1fc-4c02-f370-1c397a176775"
623640
},
624-
"execution_count": 17,
641+
"execution_count": null,
625642
"outputs": [
626643
{
627644
"output_type": "execute_result",
@@ -649,7 +666,7 @@
649666
"id": "RPcDpJmvwApE",
650667
"outputId": "bb9af1c7-30d4-4bb8-c3d5-db7daff1cc62"
651668
},
652-
"execution_count": 18,
669+
"execution_count": null,
653670
"outputs": [
654671
{
655672
"output_type": "stream",
@@ -695,7 +712,7 @@
695712
"id": "ic8GVcYXwh0z",
696713
"outputId": "0838c455-1233-4cdc-d16a-578dec21828f"
697714
},
698-
"execution_count": 19,
715+
"execution_count": null,
699716
"outputs": [
700717
{
701718
"output_type": "stream",
@@ -720,7 +737,7 @@
720737
"id": "M3QR9RyLeBKt",
721738
"outputId": "29c486f1-93a9-4d1d-c8c9-b6c76858b1ea"
722739
},
723-
"execution_count": 20,
740+
"execution_count": null,
724741
"outputs": [
725742
{
726743
"output_type": "stream",
@@ -743,7 +760,7 @@
743760
"id": "Pc0Mff0Op2xa",
744761
"outputId": "a3ad1820-7234-471e-c06c-ab74322dca6c"
745762
},
746-
"execution_count": 21,
763+
"execution_count": null,
747764
"outputs": [
748765
{
749766
"output_type": "stream",
@@ -773,7 +790,7 @@
773790
"metadata": {
774791
"id": "tlVeXWrgIbhv"
775792
},
776-
"execution_count": 22,
793+
"execution_count": null,
777794
"outputs": []
778795
},
779796
{
@@ -789,7 +806,7 @@
789806
"id": "zZyMkh4wwyg8",
790807
"outputId": "34dead37-4727-4622-f657-a4c3ae0c5405"
791808
},
792-
"execution_count": 23,
809+
"execution_count": null,
793810
"outputs": [
794811
{
795812
"output_type": "stream",
@@ -853,7 +870,7 @@
853870
"id": "Kfh7J2oXJ6KZ",
854871
"outputId": "eed7e3aa-01de-463c-edfb-1c1eb2a690f2"
855872
},
856-
"execution_count": 24,
873+
"execution_count": null,
857874
"outputs": [
858875
{
859876
"output_type": "execute_result",
@@ -884,7 +901,7 @@
884901
"metadata": {
885902
"id": "sA4sBC6teg7-"
886903
},
887-
"execution_count": 25,
904+
"execution_count": null,
888905
"outputs": []
889906
},
890907
{
@@ -899,7 +916,7 @@
899916
"id": "K0gMEMaxetF0",
900917
"outputId": "ac96d1d4-72e6-447a-ecfb-548b96c91ef5"
901918
},
902-
"execution_count": 26,
919+
"execution_count": null,
903920
"outputs": [
904921
{
905922
"output_type": "stream",
@@ -924,7 +941,7 @@
924941
"id": "qCvDUzY4tF2-",
925942
"outputId": "c23ca252-79bf-4765-d87a-8c5e0eb13dd6"
926943
},
927-
"execution_count": 27,
944+
"execution_count": null,
928945
"outputs": [
929946
{
930947
"output_type": "stream",

0 commit comments

Comments
 (0)