Skip to content

Commit 71df6d4

Browse files
committed
fix docs
1 parent bcec7fc commit 71df6d4

File tree

4 files changed

+159
-138
lines changed

4 files changed

+159
-138
lines changed

langgraph/docs/create-react-agent-memory.ipynb

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
},
5959
{
6060
"cell_type": "code",
61-
"execution_count": 9,
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": 10,
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,24 +117,35 @@
109117
},
110118
{
111119
"cell_type": "code",
112-
"execution_count": 11,
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+
"22:31:51 redisvl.index.index INFO Index already exists, not overwriting.\n",
129+
"22:31:51 redisvl.index.index INFO Index already exists, not overwriting.\n",
130+
"22:31:51 redisvl.index.index INFO Index already exists, not overwriting.\n"
131+
]
132+
}
133+
],
116134
"source": [
135+
"from typing import Literal\n",
136+
"\n",
137+
"from langchain_core.tools import tool\n",
138+
"\n",
117139
"# First we initialize the model we want to use.\n",
118140
"from langchain_openai import ChatOpenAI\n",
119141
"\n",
142+
"from langgraph.checkpoint.redis import RedisSaver\n",
143+
"from langgraph.prebuilt import create_react_agent\n",
144+
"\n",
120145
"model = ChatOpenAI(model=\"gpt-4o\", temperature=0)\n",
121146
"\n",
122147
"\n",
123148
"# For this tutorial we will use custom tool that returns pre-defined values for weather in two cities (NYC & SF)\n",
124-
"\n",
125-
"from typing import Literal\n",
126-
"\n",
127-
"from langchain_core.tools import tool\n",
128-
"\n",
129-
"\n",
130149
"@tool\n",
131150
"def get_weather(city: Literal[\"nyc\", \"sf\"]):\n",
132151
" \"\"\"Use this to get weather information.\"\"\"\n",
@@ -140,19 +159,18 @@
140159
"\n",
141160
"tools = [get_weather]\n",
142161
"\n",
143-
"# We can add \"chat memory\" to the graph with LangGraph's Redi checkpointer\n",
162+
"# We can add \"chat memory\" to the graph with LangGraph's Redis checkpointer\n",
144163
"# to retain the chat context between interactions\n",
145-
"from langgraph.checkpoint.redis import RedisSaver\n",
164+
"\n",
146165
"\n",
147166
"REDIS_URI = \"redis://redis:6379\"\n",
148167
"memory = None\n",
149168
"with RedisSaver.from_conn_string(REDIS_URI) as cp:\n",
150-
" cp.setup()\n",
151-
" memory = cp\n",
169+
" cp.setup()\n",
170+
" memory = cp\n",
152171
"\n",
153172
"# Define the graph\n",
154173
"\n",
155-
"from langgraph.prebuilt import create_react_agent\n",
156174
"\n",
157175
"graph = create_react_agent(model, tools=tools, checkpointer=memory)"
158176
]
@@ -169,7 +187,7 @@
169187
},
170188
{
171189
"cell_type": "code",
172-
"execution_count": 12,
190+
"execution_count": 4,
173191
"id": "16636975-5f2d-4dc7-ab8e-d0bea0830a28",
174192
"metadata": {},
175193
"outputs": [],
@@ -185,7 +203,7 @@
185203
},
186204
{
187205
"cell_type": "code",
188-
"execution_count": 13,
206+
"execution_count": 5,
189207
"id": "9ffff6c3-a4f5-47c9-b51d-97caaee85cd6",
190208
"metadata": {},
191209
"outputs": [
@@ -198,8 +216,8 @@
198216
"What's the weather in NYC?\n",
199217
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
200218
"Tool Calls:\n",
201-
" get_weather (call_RHv6T6OBCn7eKOlm5qEpLK4P)\n",
202-
" Call ID: call_RHv6T6OBCn7eKOlm5qEpLK4P\n",
219+
" get_weather (call_Edwfw0WiyIJ7vt9xzU9xvyeg)\n",
220+
" Call ID: call_Edwfw0WiyIJ7vt9xzU9xvyeg\n",
203221
" Args:\n",
204222
" city: nyc\n",
205223
"=================================\u001b[1m Tool Message \u001b[0m=================================\n",
@@ -229,7 +247,7 @@
229247
},
230248
{
231249
"cell_type": "code",
232-
"execution_count": 14,
250+
"execution_count": 6,
233251
"id": "187479f9-32fa-4611-9487-cf816ba2e147",
234252
"metadata": {},
235253
"outputs": [
@@ -242,7 +260,7 @@
242260
"What's it known for?\n",
243261
"==================================\u001b[1m Ai Message \u001b[0m==================================\n",
244262
"\n",
245-
"Could you please specify what \"it\" refers to? Are you asking about a specific place, person, event, or something else?\n"
263+
"Could you please specify what \"it\" refers to? Are you asking about a specific city, person, event, or something else?\n"
246264
]
247265
}
248266
],
@@ -274,3 +292,4 @@
274292
"nbformat": 4,
275293
"nbformat_minor": 5
276294
}
295+

0 commit comments

Comments
 (0)