Skip to content

Commit 46bf6bc

Browse files
committed
Fix remaining issues in section-4 notebooks
- Fixed enumerate().memories to enumerate(.memories) in 03_grounding_with_memory - Added redis_client initialization to setup cell in 05_crafting_data_for_llms - Removed duplicate redis_client creation
1 parent 45353bf commit 46bf6bc

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

python-recipes/context-engineering/notebooks/section-4-optimizations/03_grounding_with_memory.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@
431431
")\n",
432432
"\n",
433433
"print(\"\\nMemories that enable grounding:\\n\")\n",
434-
"for i, memory in enumerate(all_memories, 1).memories:\n",
434+
"for i, memory in enumerate(all_memories.memories, 1):\n",
435435
" print(f\"{i}. {memory.text}\")\n",
436436
" print(f\" Type: {memory.memory_type} | Topics: {', '.join(memory.topics)}\")\n",
437437
" print()\n",

python-recipes/context-engineering/notebooks/section-4-optimizations/05_crafting_data_for_llms.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
"memory_client = MemoryClient(config=config)\n",
173173
"llm = ChatOpenAI(model=\"gpt-4o\", temperature=0)\n",
174174
"tokenizer = tiktoken.encoding_for_model(\"gpt-4o\")\n",
175+
"redis_client = redis_config.get_redis_client()\n",
175176
"\n",
176177
"def count_tokens(text: str) -> int:\n",
177178
" return len(tokenizer.encode(text))\n",
@@ -334,7 +335,6 @@
334335
"# Step 5: Save to Redis\n",
335336
"print(\"\\n5. Saving to Redis...\")\n",
336337
"\n",
337-
"redis_client = redis_config.get_redis_client()\n",
338338
"redis_client.set(\"course_catalog_view\", catalog_view)\n",
339339
"\n",
340340
"print(\" ✅ Saved to Redis as 'course_catalog_view'\")\n",

0 commit comments

Comments
 (0)