Skip to content

Commit 7c3b86e

Browse files
committed
refactor: update notebooks
1 parent 9015b31 commit 7c3b86e

15 files changed

+1750
-305
lines changed

examples/Dockerfile.jupyter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ USER jupyter
1717
# Set up virtual environment
1818
RUN python -m venv /home/jupyter/venv
1919
ENV PATH="/home/jupyter/venv/bin:$PATH"
20+
ENV PYTHONDONTWRITEBYTECODE=1
2021

2122
# Install dependencies
2223
RUN pip install --no-cache-dir --upgrade pip && \

examples/create-react-agent-hitl.ipynb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@
121121
"output_type": "stream",
122122
"text": [
123123
"0.2.0\n",
124-
"17:25:17 langgraph.checkpoint.redis INFO Redis client is a standalone client\n"
124+
"20:54:48 langgraph.checkpoint.redis INFO Redis client is a standalone client\n"
125125
]
126126
},
127127
{
128128
"name": "stderr",
129129
"output_type": "stream",
130130
"text": [
131-
"/tmp/ipykernel_253/104821471.py:41: LangGraphDeprecatedSinceV10: create_react_agent has been moved to `langchain.agents`. Please update your import to `from langchain.agents import create_agent`. Deprecated in LangGraph V1.0 to be removed in V2.0.\n",
131+
"/tmp/ipykernel_196/104821471.py:41: LangGraphDeprecatedSinceV10: create_react_agent has been moved to `langchain.agents`. Please update your import to `from langchain.agents import create_agent`. Deprecated in LangGraph V1.0 to be removed in V2.0.\n",
132132
" graph = create_react_agent(\n"
133133
]
134134
}
@@ -217,11 +217,11 @@
217217
"================================\u001b[1m Human Message \u001b[0m=================================\n",
218218
"\n",
219219
"what is the weather in SF, CA?\n",
220-
"17:25:18 httpx INFO HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
220+
"20:54:49 httpx INFO HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
221221
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
222222
"Tool Calls:\n",
223-
" get_weather (call_5pXxdiKNI2XosSX5Vt9sbuBv)\n",
224-
" Call ID: call_5pXxdiKNI2XosSX5Vt9sbuBv\n",
223+
" get_weather (call_JQR9gMUJPiZEZ1HgkJsUYIYA)\n",
224+
" Call ID: call_JQR9gMUJPiZEZ1HgkJsUYIYA\n",
225225
" Args:\n",
226226
" location: SF, CA\n"
227227
]
@@ -254,7 +254,7 @@
254254
"name": "stdout",
255255
"output_type": "stream",
256256
"text": [
257-
"17:25:18 langgraph WARNING Ignoring invalid packet type <class 'dict'> in pending sends\n",
257+
"20:54:49 langgraph WARNING Ignoring invalid packet type <class 'dict'> in pending sends\n",
258258
"Next step: ()\n"
259259
]
260260
}
@@ -284,11 +284,11 @@
284284
"name": "stdout",
285285
"output_type": "stream",
286286
"text": [
287-
"17:25:18 langgraph WARNING Ignoring invalid packet type <class 'dict'> in pending sends\n",
287+
"20:54:49 langgraph WARNING Ignoring invalid packet type <class 'dict'> in pending sends\n",
288288
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
289289
"Tool Calls:\n",
290-
" get_weather (call_5pXxdiKNI2XosSX5Vt9sbuBv)\n",
291-
" Call ID: call_5pXxdiKNI2XosSX5Vt9sbuBv\n",
290+
" get_weather (call_JQR9gMUJPiZEZ1HgkJsUYIYA)\n",
291+
" Call ID: call_JQR9gMUJPiZEZ1HgkJsUYIYA\n",
292292
" Args:\n",
293293
" location: SF, CA\n"
294294
]
@@ -318,16 +318,16 @@
318318
"name": "stdout",
319319
"output_type": "stream",
320320
"text": [
321-
"17:25:18 langgraph WARNING Ignoring invalid packet type <class 'dict'> in pending sends\n",
322-
"17:25:18 langgraph WARNING Ignoring invalid packet type <class 'dict'> in pending sends\n"
321+
"20:54:49 langgraph WARNING Ignoring invalid packet type <class 'dict'> in pending sends\n",
322+
"20:54:49 langgraph WARNING Ignoring invalid packet type <class 'dict'> in pending sends\n"
323323
]
324324
},
325325
{
326326
"data": {
327327
"text/plain": [
328-
"{'configurable': {'thread_id': '0f79839b-117e-4aa5-901b-5c4939d92005',\n",
328+
"{'configurable': {'thread_id': '18c43cd5-0bf0-40dd-a7f2-316450e0022e',\n",
329329
" 'checkpoint_ns': '',\n",
330-
" 'checkpoint_id': '1f0c3da6-3615-6dbc-8002-bb5ce3d337c1'}}"
330+
" 'checkpoint_id': '1f0c3f7a-8519-617a-8002-a6eecd3547b9'}}"
331331
]
332332
},
333333
"execution_count": 8,
@@ -354,11 +354,11 @@
354354
"name": "stdout",
355355
"output_type": "stream",
356356
"text": [
357-
"17:25:18 langgraph WARNING Ignoring invalid packet type <class 'dict'> in pending sends\n",
357+
"20:54:49 langgraph WARNING Ignoring invalid packet type <class 'dict'> in pending sends\n",
358358
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
359359
"Tool Calls:\n",
360-
" get_weather (call_5pXxdiKNI2XosSX5Vt9sbuBv)\n",
361-
" Call ID: call_5pXxdiKNI2XosSX5Vt9sbuBv\n",
360+
" get_weather (call_JQR9gMUJPiZEZ1HgkJsUYIYA)\n",
361+
" Call ID: call_JQR9gMUJPiZEZ1HgkJsUYIYA\n",
362362
" Args:\n",
363363
" location: San Francisco\n"
364364
]

examples/create-react-agent-manage-message-history.ipynb

Lines changed: 309 additions & 35 deletions
Large diffs are not rendered by default.

examples/create-react-agent-memory.ipynb

Lines changed: 100 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
},
5959
{
6060
"cell_type": "code",
61-
"execution_count": null,
61+
"execution_count": 1,
6262
"id": "a213e11a-5c62-4ddb-a707-490d91add383",
6363
"metadata": {},
6464
"outputs": [],
@@ -69,10 +69,18 @@
6969
},
7070
{
7171
"cell_type": "code",
72-
"execution_count": null,
72+
"execution_count": 2,
7373
"id": "23a1885c-04ab-4750-aefa-105891fddf3e",
7474
"metadata": {},
75-
"outputs": [],
75+
"outputs": [
76+
{
77+
"name": "stdin",
78+
"output_type": "stream",
79+
"text": [
80+
"OPENAI_API_KEY: ········\n"
81+
]
82+
}
83+
],
7684
"source": [
7785
"import getpass\n",
7886
"import os\n",
@@ -109,10 +117,29 @@
109117
},
110118
{
111119
"cell_type": "code",
112-
"execution_count": null,
120+
"execution_count": 3,
113121
"id": "7a154152-973e-4b5d-aa13-48c617744a4c",
114122
"metadata": {},
115-
"outputs": [],
123+
"outputs": [
124+
{
125+
"name": "stdout",
126+
"output_type": "stream",
127+
"text": [
128+
"00:25:12 langgraph.checkpoint.redis INFO Redis client is a standalone client\n",
129+
"00:25:12 redisvl.index.index INFO Index already exists, not overwriting.\n",
130+
"00:25:12 redisvl.index.index INFO Index already exists, not overwriting.\n",
131+
"00:25:12 redisvl.index.index INFO Index already exists, not overwriting.\n"
132+
]
133+
},
134+
{
135+
"name": "stderr",
136+
"output_type": "stream",
137+
"text": [
138+
"/tmp/ipykernel_1924/1444546798.py:39: LangGraphDeprecatedSinceV10: create_react_agent has been moved to `langchain.agents`. Please update your import to `from langchain.agents import create_agent`. Deprecated in LangGraph V1.0 to be removed in V2.0.\n",
139+
" graph = create_react_agent(model, tools=tools, checkpointer=memory)\n"
140+
]
141+
}
142+
],
116143
"source": [
117144
"# First we initialize the model we want to use.\n",
118145
"from langchain_openai import ChatOpenAI\n",
@@ -167,7 +194,7 @@
167194
},
168195
{
169196
"cell_type": "code",
170-
"execution_count": null,
197+
"execution_count": 4,
171198
"id": "16636975-5f2d-4dc7-ab8e-d0bea0830a28",
172199
"metadata": {},
173200
"outputs": [],
@@ -183,10 +210,35 @@
183210
},
184211
{
185212
"cell_type": "code",
186-
"execution_count": null,
213+
"execution_count": 5,
187214
"id": "9ffff6c3-a4f5-47c9-b51d-97caaee85cd6",
188215
"metadata": {},
189-
"outputs": [],
216+
"outputs": [
217+
{
218+
"name": "stdout",
219+
"output_type": "stream",
220+
"text": [
221+
"================================\u001b[1m Human Message \u001b[0m=================================\n",
222+
"\n",
223+
"What's the weather in NYC?\n",
224+
"00:25:13 httpx INFO HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
225+
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
226+
"Tool Calls:\n",
227+
" get_weather (call_3ipbdgl0CGTjmjZmWDzwdDUR)\n",
228+
" Call ID: call_3ipbdgl0CGTjmjZmWDzwdDUR\n",
229+
" Args:\n",
230+
" location: New York City\n",
231+
"=================================\u001b[1m Tool Message \u001b[0m=================================\n",
232+
"Name: get_weather\n",
233+
"\n",
234+
"It might be cloudy in nyc\n",
235+
"00:25:14 httpx INFO HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
236+
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
237+
"\n",
238+
"The weather in New York City might be cloudy.\n"
239+
]
240+
}
241+
],
190242
"source": [
191243
"config = {\"configurable\": {\"thread_id\": \"1\"}}\n",
192244
"inputs = {\"messages\": [(\"user\", \"What's the weather in NYC?\")]}\n",
@@ -204,10 +256,46 @@
204256
},
205257
{
206258
"cell_type": "code",
207-
"execution_count": null,
259+
"execution_count": 6,
208260
"id": "187479f9-32fa-4611-9487-cf816ba2e147",
209261
"metadata": {},
210-
"outputs": [],
262+
"outputs": [
263+
{
264+
"name": "stdout",
265+
"output_type": "stream",
266+
"text": [
267+
"================================\u001b[1m Human Message \u001b[0m=================================\n",
268+
"\n",
269+
"What's it known for?\n",
270+
"00:25:21 httpx INFO HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
271+
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
272+
"\n",
273+
"New York City is known for many things, including:\n",
274+
"\n",
275+
"1. **Landmarks and Attractions**: The Statue of Liberty, Times Square, Central Park, Empire State Building, and Broadway theaters.\n",
276+
" \n",
277+
"2. **Cultural Diversity**: A melting pot of cultures, languages, and cuisines from around the world.\n",
278+
"\n",
279+
"3. **Financial Hub**: Home to Wall Street and the New York Stock Exchange, making it a global financial center.\n",
280+
"\n",
281+
"4. **Arts and Entertainment**: Renowned museums like the Metropolitan Museum of Art and the Museum of Modern Art, as well as a vibrant music and theater scene.\n",
282+
"\n",
283+
"5. **Fashion**: A major fashion capital, hosting New York Fashion Week and housing numerous designer boutiques.\n",
284+
"\n",
285+
"6. **Cuisine**: Famous for its diverse food scene, including iconic foods like New York-style pizza and bagels.\n",
286+
"\n",
287+
"7. **Media and Publishing**: Headquarters for major media companies and publishers, including The New York Times and NBC.\n",
288+
"\n",
289+
"8. **Skyscrapers**: Known for its impressive skyline, featuring some of the tallest buildings in the world.\n",
290+
"\n",
291+
"9. **Public Transportation**: An extensive subway system that operates 24/7, making it easy to navigate the city.\n",
292+
"\n",
293+
"10. **Sports**: Home to several major sports teams, including the New York Yankees, New York Mets, New York Knicks, and New York Giants.\n",
294+
"\n",
295+
"These are just a few highlights of what makes New York City a unique and vibrant place.\n"
296+
]
297+
}
298+
],
211299
"source": [
212300
"inputs = {\"messages\": [(\"user\", \"What's it known for?\")]}\n",
213301
"print_stream(graph.stream(inputs, config=config, stream_mode=\"values\"))"
@@ -238,9 +326,9 @@
238326
"name": "python",
239327
"nbconvert_exporter": "python",
240328
"pygments_lexer": "ipython3",
241-
"version": "3.11.13"
329+
"version": "3.11.14"
242330
}
243331
},
244332
"nbformat": 4,
245333
"nbformat_minor": 5
246-
}
334+
}

0 commit comments

Comments
 (0)