|
192 | 192 | "source": [ |
193 | 193 | "# Import the Redis Context Course components\n", |
194 | 194 | "from redis_context_course.models import Course, StudentProfile, DifficultyLevel, CourseFormat\n", |
195 | | - "from redis_context_course.memory import MemoryManager\n", |
| 195 | + "from redis_context_course.memory_client import MemoryClient\n", |
196 | 196 | "from redis_context_course.course_manager import CourseManager\n", |
197 | 197 | "from redis_context_course.redis_config import redis_config\n", |
198 | 198 | "\n", |
|
297 | 297 | ] |
298 | 298 | }, |
299 | 299 | { |
300 | | - "cell_type": "code", |
301 | | - "execution_count": null, |
| 300 | + "cell_type": "markdown", |
302 | 301 | "metadata": {}, |
303 | | - "outputs": [], |
304 | 302 | "source": [ |
| 303 | + "```python\n", |
305 | 304 | "# Initialize memory manager for our student\n", |
306 | 305 | "memory_manager = MemoryManager(\"demo_student_alex\")\n", |
307 | 306 | "\n", |
|
342 | 341 | " print(f\" • [{memory.memory_type}] {memory.content[:60]}...\")\n", |
343 | 342 | "\n", |
344 | 343 | "# Run the memory demonstration\n", |
345 | | - "import asyncio\n", |
346 | | - "await demonstrate_memory_context()" |
| 344 | + "await demonstrate_memory_context()\n", |
| 345 | + "```\n", |
| 346 | + "\n", |
| 347 | + "**Output:**\n", |
| 348 | + "```\n", |
| 349 | + "🧠 Memory Context Stored:\n", |
| 350 | + "✅ Preference stored (ID: a1b2c3d4...)\n", |
| 351 | + "✅ Goal stored (ID: e5f6g7h8...)\n", |
| 352 | + "✅ Academic performance noted (ID: i9j0k1l2...)\n", |
| 353 | + "\n", |
| 354 | + "🔍 Retrieved 3 relevant memories:\n", |
| 355 | + " • [goal] I want to specialize in machine learning and AI\n", |
| 356 | + " • [preference] I prefer online courses because I work part-time\n", |
| 357 | + " • [academic_performance] Student struggled with calculus but excelled...\n", |
| 358 | + "```" |
347 | 359 | ] |
348 | 360 | }, |
349 | 361 | { |
|
356 | 368 | ] |
357 | 369 | }, |
358 | 370 | { |
359 | | - "cell_type": "code", |
360 | | - "execution_count": null, |
| 371 | + "cell_type": "markdown", |
361 | 372 | "metadata": {}, |
362 | | - "outputs": [], |
363 | 373 | "source": [ |
| 374 | + "**Example: Context Integration in Practice**\n", |
| 375 | + "\n", |
| 376 | + "```python\n", |
364 | 377 | "# Simulate how context is integrated for a recommendation\n", |
365 | 378 | "async def demonstrate_context_integration():\n", |
366 | 379 | " print(\"🎯 Context Integration Example\")\n", |
|
374 | 387 | " print(\"\\n🔍 Retrieving Context...\")\n", |
375 | 388 | " \n", |
376 | 389 | " # Get student context from memory\n", |
377 | | - " student_context = await memory_manager.get_student_context(query)\n", |
| 390 | + " student_context = await memory_client.search_memories(query, limit=5)\n", |
378 | 391 | " \n", |
379 | 392 | " print(\"📋 Available Context:\")\n", |
380 | 393 | " print(f\" • System Role: University Class Agent\")\n", |
381 | | - " print(f\" • Student: {student.name} ({student.major}, Year {student.year})\")\n", |
382 | | - " print(f\" • Completed Courses: {len(student.completed_courses)}\")\n", |
383 | | - " print(f\" • Preferences: {student.preferred_format.value} format\")\n", |
384 | | - " print(f\" • Interests: {', '.join(student.interests[:2])}...\")\n", |
385 | | - " print(f\" • Stored Memories: {len(student_context.get('preferences', []))} preferences, {len(student_context.get('goals', []))} goals\")\n", |
| 394 | + " print(f\" • Student: Alex Chen (Computer Science, Year 3)\")\n", |
| 395 | + " print(f\" • Completed Courses: 15\")\n", |
| 396 | + " print(f\" • Preferences: Online format\")\n", |
| 397 | + " print(f\" • Interests: Machine Learning, Web Development...\")\n", |
| 398 | + " print(f\" • Stored Memories: 3 preferences, 2 goals\")\n", |
386 | 399 | " \n", |
387 | 400 | " # 3. Generate contextual response\n", |
388 | 401 | " print(\"\\n🤖 Agent Response (Context-Aware):\")\n", |
389 | 402 | " print(\"-\" * 40)\n", |
390 | | - " \n", |
391 | | - " contextual_response = f\"\"\"\n", |
392 | | - "Based on your profile and our previous conversations, here are my recommendations for next semester:\n", |
| 403 | + " print(\"\"\"\n", |
| 404 | + "Based on your profile and our previous conversations, here are my recommendations:\n", |
393 | 405 | "\n", |
394 | | - "🎯 **Personalized for {student.name}:**\n", |
395 | | - "• Major: {student.major} (Year {student.year})\n", |
396 | | - "• Format Preference: {student.preferred_format.value} courses\n", |
397 | | - "• Interest in: {', '.join(student.interests)}\n", |
| 406 | + "🎯 **Personalized for Alex Chen:**\n", |
| 407 | + "• Major: Computer Science (Year 3)\n", |
| 408 | + "• Format Preference: Online courses\n", |
| 409 | + "• Interest in: Machine Learning, Web Development\n", |
398 | 410 | "• Goal: Specialize in machine learning and AI\n", |
399 | 411 | "\n", |
400 | 412 | "📚 **Recommended Courses:**\n", |
401 | 413 | "1. **CS301: Machine Learning Fundamentals** (Online)\n", |
402 | 414 | " - Aligns with your AI specialization goal\n", |
403 | 415 | " - Online format matches your work schedule\n", |
404 | | - " - Prerequisite CS201 ✅ (currently taking)\n", |
405 | 416 | "\n", |
406 | 417 | "2. **CS250: Web Development** (Hybrid)\n", |
407 | 418 | " - Matches your web development interest\n", |
408 | 419 | " - Practical skills for part-time work\n", |
409 | | - " - No additional prerequisites needed\n", |
410 | 420 | "\n", |
411 | 421 | "3. **MATH301: Statistics for Data Science** (Online)\n", |
412 | 422 | " - Essential for machine learning\n", |
413 | 423 | " - Builds on your completed MATH201\n", |
414 | | - " - Online format preferred\n", |
415 | 424 | "\n", |
416 | 425 | "💡 **Why these recommendations:**\n", |
417 | 426 | "• All courses align with your machine learning career goal\n", |
418 | 427 | "• Prioritized online/hybrid formats for your work schedule\n", |
419 | | - "• Considered your strong programming background\n", |
420 | 428 | "• Total: 10 credits (within your 15-credit preference)\n", |
421 | | - "\"\"\"\n", |
422 | | - " \n", |
423 | | - " print(contextual_response)\n", |
| 429 | + "\"\"\")\n", |
| 430 | + "\n", |
| 431 | + "await demonstrate_context_integration()\n", |
| 432 | + "```\n", |
424 | 433 | "\n", |
425 | | - "await demonstrate_context_integration()" |
| 434 | + "This example shows how the agent combines multiple context sources to provide personalized, relevant recommendations." |
426 | 435 | ] |
427 | 436 | }, |
428 | 437 | { |
|
0 commit comments