Skip to content

Commit a92fe1e

Browse files
committed
Fix Redis get() calls in 05_crafting_data_for_llms
Removed .decode() calls since redis_client is configured with decode_responses=True. Added None checks to handle missing data.
1 parent 1168b32 commit a92fe1e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
"# Load and use the view\n",
364364
"print(\"\\nUsing the catalog view in an agent...\\n\")\n",
365365
"\n",
366-
"catalog_view = redis_client.get(\"course_catalog_view\").decode('utf-8')\n",
366+
"catalog_view = redis_client.get(\"course_catalog_view\") or \"\"\n",
367367
"\n",
368368
"system_prompt = f\"\"\"You are a class scheduling agent for Redis University.\n",
369369
"\n",
@@ -592,7 +592,8 @@
592592
"# Load and use the profile\n",
593593
"print(\"\\nUsing the profile view in an agent...\\n\")\n",
594594
"\n",
595-
"profile_json = json.loads(redis_client.get(f\"user_profile:{user_data['student_id']}\").decode('utf-8'))\n",
595+
"profile_data = redis_client.get(f\"user_profile:{user_data['student_id']}\")\n",
596+
"profile_json = json.loads(profile_data) if profile_data else {}\n",
596597
"profile_text = profile_json['profile_text']\n",
597598
"\n",
598599
"system_prompt = f\"\"\"You are a class scheduling agent for Redis University.\n",

0 commit comments

Comments
 (0)