Skip to content

Commit 9a9c287

Browse files
committed
docs(notebook): update human_in_the_loop and memory notebooks
- Clear all outputs for clean execution on all 11 notebooks - 7 human_in_the_loop notebooks: breakpoints, dynamic_breakpoints, edit-graph-state, review-tool-calls-openai, review-tool-calls, time-travel, wait-user-input - 4 memory notebooks: add-summary-conversation-history, delete-messages, manage-conversation-history, semantic-search - Ready for end-to-end execution with Redis checkpoint
1 parent 6310dc6 commit 9a9c287

11 files changed

+246
-1958
lines changed

examples/human_in_the_loop/breakpoints.ipynb

Lines changed: 13 additions & 127 deletions
Large diffs are not rendered by default.

examples/human_in_the_loop/dynamic_breakpoints.ipynb

Lines changed: 24 additions & 177 deletions
Large diffs are not rendered by default.

examples/human_in_the_loop/edit-graph-state.ipynb

Lines changed: 22 additions & 165 deletions
Large diffs are not rendered by default.

examples/human_in_the_loop/review-tool-calls-openai.ipynb

Lines changed: 30 additions & 225 deletions
Large diffs are not rendered by default.

examples/human_in_the_loop/review-tool-calls.ipynb

Lines changed: 30 additions & 225 deletions
Large diffs are not rendered by default.

examples/human_in_the_loop/time-travel.ipynb

Lines changed: 32 additions & 231 deletions
Large diffs are not rendered by default.

examples/human_in_the_loop/wait-user-input.ipynb

Lines changed: 20 additions & 176 deletions
Large diffs are not rendered by default.

examples/memory/add-summary-conversation-history.ipynb

Lines changed: 21 additions & 230 deletions
Large diffs are not rendered by default.

examples/memory/delete-messages.ipynb

Lines changed: 20 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
{
3030
"cell_type": "code",
31-
"execution_count": 1,
31+
"execution_count": null,
3232
"id": "af4ce0ba-7596-4e5f-8bf8-0b0bd6e62833",
3333
"metadata": {},
3434
"outputs": [],
@@ -47,18 +47,10 @@
4747
},
4848
{
4949
"cell_type": "code",
50-
"execution_count": 2,
50+
"execution_count": null,
5151
"id": "c903a1cf-2977-4e2d-ad7d-8b3946821d89",
5252
"metadata": {},
53-
"outputs": [
54-
{
55-
"name": "stdin",
56-
"output_type": "stream",
57-
"text": [
58-
"ANTHROPIC_API_KEY: ········\n"
59-
]
60-
}
61-
],
53+
"outputs": [],
6254
"source": [
6355
"import getpass\n",
6456
"import os\n",
@@ -96,21 +88,10 @@
9688
},
9789
{
9890
"cell_type": "code",
99-
"execution_count": 3,
91+
"execution_count": null,
10092
"id": "378899a9-3b9a-4748-95b6-eb00e0828677",
10193
"metadata": {},
102-
"outputs": [
103-
{
104-
"name": "stdout",
105-
"output_type": "stream",
106-
"text": [
107-
"19:50:41 langgraph.checkpoint.redis INFO Redis client is a standalone client\n",
108-
"19:50:41 redisvl.index.index INFO Index already exists, not overwriting.\n",
109-
"19:50:41 redisvl.index.index INFO Index already exists, not overwriting.\n",
110-
"19:50:41 redisvl.index.index INFO Index already exists, not overwriting.\n"
111-
]
112-
}
113-
],
94+
"outputs": [],
11495
"source": [
11596
"from typing import Literal\n",
11697
"\n",
@@ -194,31 +175,10 @@
194175
},
195176
{
196177
"cell_type": "code",
197-
"execution_count": 4,
178+
"execution_count": null,
198179
"id": "57b27553-21be-43e5-ac48-d1d0a3aa0dca",
199180
"metadata": {},
200-
"outputs": [
201-
{
202-
"name": "stdout",
203-
"output_type": "stream",
204-
"text": [
205-
"================================\u001b[1m Human Message \u001b[0m=================================\n",
206-
"\n",
207-
"hi! I'm bob\n",
208-
"19:50:42 httpx INFO HTTP Request: POST https://api.anthropic.com/v1/messages \"HTTP/1.1 200 OK\"\n",
209-
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
210-
"\n",
211-
"Nice to meet you, Bob! How are you doing today?\n",
212-
"================================\u001b[1m Human Message \u001b[0m=================================\n",
213-
"\n",
214-
"what's my name?\n",
215-
"19:50:42 httpx INFO HTTP Request: POST https://api.anthropic.com/v1/messages \"HTTP/1.1 200 OK\"\n",
216-
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
217-
"\n",
218-
"Your name is Bob, as you introduced yourself earlier.\n"
219-
]
220-
}
221-
],
181+
"outputs": [],
222182
"source": [
223183
"from langchain_core.messages import HumanMessage\n",
224184
"\n",
@@ -244,27 +204,10 @@
244204
},
245205
{
246206
"cell_type": "code",
247-
"execution_count": 5,
207+
"execution_count": null,
248208
"id": "8a850529-d038-48f7-b5a2-8d4d2923f83a",
249209
"metadata": {},
250-
"outputs": [
251-
{
252-
"data": {
253-
"text/plain": [
254-
"[HumanMessage(content=\"what's the weather in sf\", additional_kwargs={}, response_metadata={}, id='d7fc45f1-6c5d-4b8b-8b5d-2040d25e9ee4'),\n",
255-
" HumanMessage(content=\"what's the weather in sf\", additional_kwargs={}, response_metadata={}, id='28ef5b05-b571-4454-9753-10d194e52024'),\n",
256-
" AIMessage(content='rainy', additional_kwargs={}, response_metadata={}, id='9773b21f-7e75-4e67-91a8-5ab80fa37ee7'),\n",
257-
" HumanMessage(content=\"hi! I'm bob\", additional_kwargs={}, response_metadata={}, id='2d0c503b-9df6-4570-af9f-79b9836feb93'),\n",
258-
" AIMessage(content='Nice to meet you, Bob! How are you doing today?', additional_kwargs={}, response_metadata={'id': 'msg_018qjMF2rCeDopVNXyDUV2gs', 'model': 'claude-3-haiku-20240307', 'stop_reason': 'end_turn', 'stop_sequence': None, 'usage': {'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 0, 'input_tokens': 33, 'output_tokens': 16, 'server_tool_use': None, 'service_tier': 'standard'}, 'model_name': 'claude-3-haiku-20240307'}, id='run--f9412a3a-0228-4711-a34e-cd61408bfedd-0', usage_metadata={'input_tokens': 33, 'output_tokens': 16, 'total_tokens': 49, 'input_token_details': {'cache_creation': 0, 'cache_read': 0}}),\n",
259-
" HumanMessage(content=\"what's my name?\", additional_kwargs={}, response_metadata={}, id='a93a4f72-2c30-4129-ab05-af7746b60af1'),\n",
260-
" AIMessage(content='Your name is Bob, as you introduced yourself earlier.', additional_kwargs={}, response_metadata={'id': 'msg_01Gpz8yNWvUXbdLBAqnnEgac', 'model': 'claude-3-haiku-20240307', 'stop_reason': 'end_turn', 'stop_sequence': None, 'usage': {'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 0, 'input_tokens': 57, 'output_tokens': 14, 'server_tool_use': None, 'service_tier': 'standard'}, 'model_name': 'claude-3-haiku-20240307'}, id='run--1c8a9de5-8ccc-4832-92ce-84998c7867b7-0', usage_metadata={'input_tokens': 57, 'output_tokens': 14, 'total_tokens': 71, 'input_token_details': {'cache_creation': 0, 'cache_read': 0}})]"
261-
]
262-
},
263-
"execution_count": 5,
264-
"metadata": {},
265-
"output_type": "execute_result"
266-
}
267-
],
210+
"outputs": [],
268211
"source": [
269212
"messages = app.get_state(config).values[\"messages\"]\n",
270213
"messages"
@@ -280,23 +223,10 @@
280223
},
281224
{
282225
"cell_type": "code",
283-
"execution_count": 6,
226+
"execution_count": null,
284227
"id": "df1a0970-7e64-4170-beef-2855d10eef42",
285228
"metadata": {},
286-
"outputs": [
287-
{
288-
"data": {
289-
"text/plain": [
290-
"{'configurable': {'thread_id': '2',\n",
291-
" 'checkpoint_ns': '',\n",
292-
" 'checkpoint_id': '1f072fea-2e9f-6bfc-800c-832ea93dceea'}}"
293-
]
294-
},
295-
"execution_count": 6,
296-
"metadata": {},
297-
"output_type": "execute_result"
298-
}
299-
],
229+
"outputs": [],
300230
"source": [
301231
"from langchain_core.messages import RemoveMessage\n",
302232
"\n",
@@ -313,26 +243,10 @@
313243
},
314244
{
315245
"cell_type": "code",
316-
"execution_count": 7,
246+
"execution_count": null,
317247
"id": "8bfe4ffa-e170-43bc-aec4-6e36ac620931",
318248
"metadata": {},
319-
"outputs": [
320-
{
321-
"data": {
322-
"text/plain": [
323-
"[HumanMessage(content=\"what's the weather in sf\", additional_kwargs={}, response_metadata={}, id='28ef5b05-b571-4454-9753-10d194e52024'),\n",
324-
" AIMessage(content='rainy', additional_kwargs={}, response_metadata={}, id='9773b21f-7e75-4e67-91a8-5ab80fa37ee7'),\n",
325-
" HumanMessage(content=\"hi! I'm bob\", additional_kwargs={}, response_metadata={}, id='2d0c503b-9df6-4570-af9f-79b9836feb93'),\n",
326-
" AIMessage(content='Nice to meet you, Bob! How are you doing today?', additional_kwargs={}, response_metadata={'id': 'msg_018qjMF2rCeDopVNXyDUV2gs', 'model': 'claude-3-haiku-20240307', 'stop_reason': 'end_turn', 'stop_sequence': None, 'usage': {'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 0, 'input_tokens': 33, 'output_tokens': 16, 'server_tool_use': None, 'service_tier': 'standard'}, 'model_name': 'claude-3-haiku-20240307'}, id='run--f9412a3a-0228-4711-a34e-cd61408bfedd-0', usage_metadata={'input_tokens': 33, 'output_tokens': 16, 'total_tokens': 49, 'input_token_details': {'cache_creation': 0, 'cache_read': 0}}),\n",
327-
" HumanMessage(content=\"what's my name?\", additional_kwargs={}, response_metadata={}, id='a93a4f72-2c30-4129-ab05-af7746b60af1'),\n",
328-
" AIMessage(content='Your name is Bob, as you introduced yourself earlier.', additional_kwargs={}, response_metadata={'id': 'msg_01Gpz8yNWvUXbdLBAqnnEgac', 'model': 'claude-3-haiku-20240307', 'stop_reason': 'end_turn', 'stop_sequence': None, 'usage': {'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 0, 'input_tokens': 57, 'output_tokens': 14, 'server_tool_use': None, 'service_tier': 'standard'}, 'model_name': 'claude-3-haiku-20240307'}, id='run--1c8a9de5-8ccc-4832-92ce-84998c7867b7-0', usage_metadata={'input_tokens': 57, 'output_tokens': 14, 'total_tokens': 71, 'input_token_details': {'cache_creation': 0, 'cache_read': 0}})]"
329-
]
330-
},
331-
"execution_count": 7,
332-
"metadata": {},
333-
"output_type": "execute_result"
334-
}
335-
],
249+
"outputs": [],
336250
"source": [
337251
"messages = app.get_state(config).values[\"messages\"]\n",
338252
"messages"
@@ -350,21 +264,10 @@
350264
},
351265
{
352266
"cell_type": "code",
353-
"execution_count": 8,
267+
"execution_count": null,
354268
"id": "bb22ede0-e153-4fd0-a4c0-f9af2f7663b1",
355269
"metadata": {},
356-
"outputs": [
357-
{
358-
"name": "stdout",
359-
"output_type": "stream",
360-
"text": [
361-
"19:50:42 langgraph.checkpoint.redis INFO Redis client is a standalone client\n",
362-
"19:50:42 redisvl.index.index INFO Index already exists, not overwriting.\n",
363-
"19:50:42 redisvl.index.index INFO Index already exists, not overwriting.\n",
364-
"19:50:42 redisvl.index.index INFO Index already exists, not overwriting.\n"
365-
]
366-
}
367-
],
270+
"outputs": [],
368271
"source": [
369272
"from langchain_core.messages import RemoveMessage\n",
370273
"from langgraph.graph import END\n",
@@ -426,25 +329,10 @@
426329
},
427330
{
428331
"cell_type": "code",
429-
"execution_count": 9,
332+
"execution_count": null,
430333
"id": "3975f34c-c243-40ea-b9d2-424d50a48dc9",
431334
"metadata": {},
432-
"outputs": [
433-
{
434-
"name": "stdout",
435-
"output_type": "stream",
436-
"text": [
437-
"[('human', \"what's the weather in sf\"), ('ai', \"It's sunny in San Francisco!\"), ('human', \"hi! I'm bob\")]\n",
438-
"19:50:43 httpx INFO HTTP Request: POST https://api.anthropic.com/v1/messages \"HTTP/1.1 200 OK\"\n",
439-
"[('human', \"what's the weather in sf\"), ('ai', \"It's sunny in San Francisco!\"), ('human', \"hi! I'm bob\"), ('ai', \"Hi Bob, it's nice to meet you! As an AI assistant, I don't have a physical form, but I'm happy to chat and try my best to help you with any questions or tasks you might have. Please let me know if there's anything I can assist you with.\")]\n",
440-
"[('ai', \"It's sunny in San Francisco!\"), ('human', \"hi! I'm bob\"), ('ai', \"Hi Bob, it's nice to meet you! As an AI assistant, I don't have a physical form, but I'm happy to chat and try my best to help you with any questions or tasks you might have. Please let me know if there's anything I can assist you with.\")]\n",
441-
"[('ai', \"It's sunny in San Francisco!\"), ('human', \"hi! I'm bob\"), ('ai', \"Hi Bob, it's nice to meet you! As an AI assistant, I don't have a physical form, but I'm happy to chat and try my best to help you with any questions or tasks you might have. Please let me know if there's anything I can assist you with.\"), ('human', \"what's my name?\")]\n",
442-
"19:50:44 httpx INFO HTTP Request: POST https://api.anthropic.com/v1/messages \"HTTP/1.1 200 OK\"\n",
443-
"[('ai', \"It's sunny in San Francisco!\"), ('human', \"hi! I'm bob\"), ('ai', \"Hi Bob, it's nice to meet you! As an AI assistant, I don't have a physical form, but I'm happy to chat and try my best to help you with any questions or tasks you might have. Please let me know if there's anything I can assist you with.\"), ('human', \"what's my name?\"), ('ai', 'You said your name is Bob, so your name is Bob.')]\n",
444-
"[('ai', \"Hi Bob, it's nice to meet you! As an AI assistant, I don't have a physical form, but I'm happy to chat and try my best to help you with any questions or tasks you might have. Please let me know if there's anything I can assist you with.\"), ('human', \"what's my name?\"), ('ai', 'You said your name is Bob, so your name is Bob.')]\n"
445-
]
446-
}
447-
],
335+
"outputs": [],
448336
"source": [
449337
"from langchain_core.messages import HumanMessage\n",
450338
"\n",
@@ -468,23 +356,10 @@
468356
},
469357
{
470358
"cell_type": "code",
471-
"execution_count": 10,
359+
"execution_count": null,
472360
"id": "a3e15abb-81d8-4072-9f10-61ae0fd61dac",
473361
"metadata": {},
474-
"outputs": [
475-
{
476-
"data": {
477-
"text/plain": [
478-
"[AIMessage(content=\"Hi Bob, it's nice to meet you! As an AI assistant, I don't have a physical form, but I'm happy to chat and try my best to help you with any questions or tasks you might have. Please let me know if there's anything I can assist you with.\", additional_kwargs={}, response_metadata={'id': 'msg_018GPgXGZTAEVaMepCSqpnd6', 'model': 'claude-3-haiku-20240307', 'stop_reason': 'end_turn', 'stop_sequence': None, 'usage': {'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 0, 'input_tokens': 31, 'output_tokens': 62, 'server_tool_use': None, 'service_tier': 'standard'}, 'model_name': 'claude-3-haiku-20240307'}, id='run--8257b47e-e5b1-4e79-ac0c-6d3dfa9f2e10-0', usage_metadata={'input_tokens': 31, 'output_tokens': 62, 'total_tokens': 93, 'input_token_details': {'cache_creation': 0, 'cache_read': 0}}),\n",
479-
" HumanMessage(content=\"what's my name?\", additional_kwargs={}, response_metadata={}, id='aee629b9-daa6-4e62-8acb-10aff78c9a2b'),\n",
480-
" AIMessage(content='You said your name is Bob, so your name is Bob.', additional_kwargs={}, response_metadata={'id': 'msg_01Jx5JcjsiavCyyzn4ErHX7w', 'model': 'claude-3-haiku-20240307', 'stop_reason': 'end_turn', 'stop_sequence': None, 'usage': {'cache_creation_input_tokens': 0, 'cache_read_input_tokens': 0, 'input_tokens': 104, 'output_tokens': 16, 'server_tool_use': None, 'service_tier': 'standard'}, 'model_name': 'claude-3-haiku-20240307'}, id='run--90a3132d-d1b0-4c97-aa72-56fe5731a9d3-0', usage_metadata={'input_tokens': 104, 'output_tokens': 16, 'total_tokens': 120, 'input_token_details': {'cache_creation': 0, 'cache_read': 0}})]"
481-
]
482-
},
483-
"execution_count": 10,
484-
"metadata": {},
485-
"output_type": "execute_result"
486-
}
487-
],
362+
"outputs": [],
488363
"source": [
489364
"messages = app.get_state(config).values[\"messages\"]\n",
490365
"messages"
@@ -520,4 +395,4 @@
520395
},
521396
"nbformat": 4,
522397
"nbformat_minor": 5
523-
}
398+
}

0 commit comments

Comments
 (0)