Skip to content

Commit 578dff5

Browse files
committed
Format notebooks
1 parent 71884c2 commit 578dff5

14 files changed

+2887
-3560
lines changed

python-recipes/context-engineering/notebooks/section-1-context-engineering-foundations/01_introduction_context_engineering_old.ipynb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,34 +174,34 @@
174174
],
175175
"source": [
176176
"import os\n",
177+
"\n",
177178
"from openai import OpenAI\n",
178179
"\n",
179180
"# Initialize OpenAI client (for demonstration - API key needed for actual calls)\n",
180181
"api_key = os.getenv(\"OPENAI_API_KEY\", \"demo-key-for-notebook\")\n",
181182
"client = OpenAI(api_key=api_key) if api_key != \"demo-key-for-notebook\" else None\n",
182183
"\n",
184+
"\n",
183185
"def ask_agent(messages, system_prompt=\"You are a helpful assistant.\"):\n",
184186
" \"\"\"Simple function to call OpenAI with context\"\"\"\n",
185187
" if client and api_key != \"demo-key-for-notebook\":\n",
186188
" # Real OpenAI API call\n",
187189
" response = client.chat.completions.create(\n",
188190
" model=\"gpt-4o-mini\",\n",
189-
" messages=[\n",
190-
" {\"role\": \"system\", \"content\": system_prompt},\n",
191-
" *messages\n",
192-
" ]\n",
191+
" messages=[{\"role\": \"system\", \"content\": system_prompt}, *messages],\n",
193192
" )\n",
194193
" return response.choices[0].message.content\n",
195194
" else:\n",
196195
" # Demo response for notebook execution\n",
197-
" user_content = messages[0]['content'] if messages else \"general query\"\n",
196+
" user_content = messages[0][\"content\"] if messages else \"general query\"\n",
198197
" if \"Redis course\" in user_content:\n",
199198
" return \"Based on your background and goals, I recommend starting with RU101 (Introduction to Redis) to build a solid foundation, then progressing to RU201 (Redis for Python) which aligns with your programming experience and interests.\"\n",
200199
" elif \"long will that take\" in user_content:\n",
201200
" return \"RU201 (Redis for Python) typically takes 6-8 hours to complete, including hands-on exercises. Given your evening and weekend availability, you could finish it in 2-3 weeks at a comfortable pace.\"\n",
202201
" else:\n",
203202
" return \"I'd be happy to help with your Redis learning journey. Could you tell me more about your background and what you're hoping to achieve?\"\n",
204203
"\n",
204+
"\n",
205205
"print(\"Setup complete! (Using demo responses - set OPENAI_API_KEY for real API calls)\")"
206206
]
207207
},
@@ -325,15 +325,17 @@
325325
" \"preferred_format\": \"online\",\n",
326326
" \"preferred_difficulty\": \"intermediate\",\n",
327327
" \"learning_style\": \"hands-on projects\",\n",
328-
" \"time_availability\": \"evenings and weekends\"\n",
328+
" \"time_availability\": \"evenings and weekends\",\n",
329329
"}\n",
330330
"\n",
331331
"print(\"Student Profile Example:\")\n",
332332
"print(f\"Name: {student_profile['name']}\")\n",
333333
"print(f\"Major: {student_profile['major']}\")\n",
334334
"print(f\"Interests: {', '.join(student_profile['interests'])}\")\n",
335335
"print(f\"Completed: {len(student_profile['completed_courses'])} courses\")\n",
336-
"print(f\"Preferences: {student_profile['preferred_format']}, {student_profile['preferred_difficulty']} level\")"
336+
"print(\n",
337+
" f\"Preferences: {student_profile['preferred_format']}, {student_profile['preferred_difficulty']} level\"\n",
338+
")"
337339
]
338340
},
339341
{

python-recipes/context-engineering/notebooks/section-1-context-engineering-foundations/01_what_is_context_engineering.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@
321321
"\n",
322322
"📚 **Read the full paper:** [Context Rot: How Increasing Input Tokens Impacts LLM Performance](https://research.trychroma.com/context-rot)\n",
323323
"\n",
324+
"**💡 Preview:** In Section 3, you'll learn compression strategies (truncation, summarization, priority-based) that directly address context rot by managing conversation length while preserving quality. These techniques solve the \"Lost in the Middle\" problem by keeping context focused and well-organized.\n",
325+
"\n",
324326
"---"
325327
]
326328
},

0 commit comments

Comments
 (0)