Skip to content

Commit d6b36b0

Browse files
committed
Fix ClientMemoryRecord memory_type - use string not MemoryType filter
ClientMemoryRecord.memory_type expects a string (or MemoryTypeEnum), not a MemoryType filter object. The MemoryType filter is only for search parameters. Changed back: - memory_type=MemoryType(eq=\semantic\) -> memory_type=\semantic\ - memory_type=MemoryType(eq=\episodic\) -> memory_type=\episodic\ The MemoryType filter is still used correctly in search_long_term_memory calls.
1 parent 7780258 commit d6b36b0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

python-recipes/context-engineering/notebooks/section-3-memory/02_long_term_memory.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,25 +146,25 @@
146146
"# Store student preferences\n",
147147
"await memory_client.create_long_term_memory([ClientMemoryRecord(\n",
148148
" text=\"Student prefers online courses over in-person classes\",\n",
149-
" memory_type=MemoryType(eq=\"semantic\"),\n",
149+
" memory_type=\"semantic\",\n",
150150
" topics=[\"preferences\", \"course_format\"]\n",
151151
")])\n",
152152
"\n",
153153
"await memory_client.create_long_term_memory([ClientMemoryRecord(\n",
154154
" text=\"Student's major is Computer Science with a focus on AI/ML\",\n",
155-
" memory_type=MemoryType(eq=\"semantic\"),\n",
155+
" memory_type=\"semantic\",\n",
156156
" topics=[\"academic_info\", \"major\"]\n",
157157
")])\n",
158158
"\n",
159159
"await memory_client.create_long_term_memory([ClientMemoryRecord(\n",
160160
" text=\"Student wants to graduate in Spring 2026\",\n",
161-
" memory_type=MemoryType(eq=\"semantic\"),\n",
161+
" memory_type=\"semantic\",\n",
162162
" topics=[\"goals\", \"graduation\"]\n",
163163
")])\n",
164164
"\n",
165165
"await memory_client.create_long_term_memory([ClientMemoryRecord(\n",
166166
" text=\"Student prefers morning classes, no classes on Fridays\",\n",
167-
" memory_type=MemoryType(eq=\"semantic\"),\n",
167+
" memory_type=\"semantic\",\n",
168168
" topics=[\"preferences\", \"schedule\"]\n",
169169
")])\n",
170170
"\n",
@@ -189,21 +189,21 @@
189189
"# Store course enrollment events\n",
190190
"await memory_client.create_long_term_memory([ClientMemoryRecord(\n",
191191
" text=\"Student enrolled in CS101: Introduction to Programming on 2024-09-01\",\n",
192-
" memory_type=MemoryType(eq=\"episodic\"),\n",
192+
" memory_type=\"episodic\",\n",
193193
" topics=[\"enrollment\", \"courses\"],\n",
194194
" metadata={\"course_code\": \"CS101\", \"date\": \"2024-09-01\"}\n",
195195
")])\n",
196196
"\n",
197197
"await memory_client.create_long_term_memory([ClientMemoryRecord(\n",
198198
" text=\"Student completed CS101 with grade A on 2024-12-15\",\n",
199-
" memory_type=MemoryType(eq=\"episodic\"),\n",
199+
" memory_type=\"episodic\",\n",
200200
" topics=[\"completion\", \"grades\"],\n",
201201
" metadata={\"course_code\": \"CS101\", \"grade\": \"A\", \"date\": \"2024-12-15\"}\n",
202202
")])\n",
203203
"\n",
204204
"await memory_client.create_long_term_memory([ClientMemoryRecord(\n",
205205
" text=\"Student asked about machine learning courses on 2024-09-20\",\n",
206-
" memory_type=MemoryType(eq=\"episodic\"),\n",
206+
" memory_type=\"episodic\",\n",
207207
" topics=[\"inquiry\", \"machine_learning\"],\n",
208208
" metadata={\"date\": \"2024-09-20\"}\n",
209209
")])\n",
@@ -299,7 +299,7 @@
299299
"try:\n",
300300
" await memory_client.create_long_term_memory([ClientMemoryRecord(\n",
301301
" text=\"Student prefers online courses over in-person classes\",\n",
302-
" memory_type=MemoryType(eq=\"semantic\"),\n",
302+
" memory_type=\"semantic\",\n",
303303
" topics=[\"preferences\", \"course_format\"]\n",
304304
")])\n",
305305
" print(\"❌ Duplicate was stored (unexpected)\")\n",
@@ -311,7 +311,7 @@
311311
"try:\n",
312312
" await memory_client.create_long_term_memory([ClientMemoryRecord(\n",
313313
" text=\"Student likes taking classes online instead of on campus\",\n",
314-
" memory_type=MemoryType(eq=\"semantic\"),\n",
314+
" memory_type=\"semantic\",\n",
315315
" topics=[\"preferences\", \"course_format\"]\n",
316316
")])\n",
317317
" print(\"Memory stored (may be merged with existing similar memory)\")\n",

0 commit comments

Comments
 (0)