|
50 | 50 | "\n", |
51 | 51 | "### 2. **Memory Management**\n", |
52 | 52 | "How information is stored, retrieved, and maintained:\n", |
53 | | - "- **Short-term memory**: Current conversation and immediate context\n", |
| 53 | + "- **Working memory**: Current conversation and immediate context\n", |
54 | 54 | "- **Long-term memory**: Persistent knowledge and experiences\n", |
55 | | - "- **Working memory**: Active information being processed\n", |
56 | 55 | "\n", |
57 | 56 | "### 3. **Context Retrieval**\n", |
58 | 57 | "How relevant information is found and surfaced:\n", |
|
115 | 114 | "import sys\n", |
116 | 115 | "import os\n", |
117 | 116 | "\n", |
118 | | - "try:\n", |
119 | | - " # Try to install the package in development mode\n", |
120 | | - " package_path = \"../../reference-agent\"\n", |
121 | | - " if os.path.exists(package_path):\n", |
122 | | - " result = subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"-q\", \"-e\", package_path], \n", |
123 | | - " capture_output=True, text=True)\n", |
124 | | - " if result.returncode == 0:\n", |
125 | | - " print(\"✅ Package installed successfully\")\n", |
126 | | - " else:\n", |
127 | | - " print(f\"⚠️ Package installation failed: {result.stderr}\")\n", |
128 | | - " print(\"📝 This is expected in CI environments - continuing with demonstration\")\n", |
129 | | - " else:\n", |
130 | | - " print(\"⚠️ Package path not found - this is expected in CI environments\")\n", |
131 | | - " print(\"📝 Continuing with demonstration using mock objects\")\n", |
132 | | - "except Exception as e:\n", |
133 | | - " print(f\"⚠️ Installation error: {e}\")\n", |
134 | | - " print(\"📝 This is expected in CI environments - continuing with demonstration\")" |
| 117 | + "# Install the package in development mode\n", |
| 118 | + "package_path = \"../../reference-agent\"\n", |
| 119 | + "result = subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"-q\", \"-e\", package_path], \n", |
| 120 | + " capture_output=True, text=True)\n", |
| 121 | + "if result.returncode == 0:\n", |
| 122 | + " print(\"✅ Package installed successfully\")\n", |
| 123 | + "else:\n", |
| 124 | + " print(f\"❌ Package installation failed: {result.stderr}\")\n", |
| 125 | + " raise RuntimeError(f\"Failed to install package: {result.stderr}\")" |
135 | 126 | ] |
136 | 127 | }, |
137 | 128 | { |
|
199 | 190 | "metadata": {}, |
200 | 191 | "outputs": [], |
201 | 192 | "source": [ |
202 | | - "# Import the Redis Context Course components with error handling\n", |
203 | | - "try:\n", |
204 | | - " from redis_context_course.models import Course, StudentProfile, DifficultyLevel, CourseFormat\n", |
205 | | - " from redis_context_course.memory import MemoryManager\n", |
206 | | - " from redis_context_course.course_manager import CourseManager\n", |
207 | | - " from redis_context_course.redis_config import redis_config\n", |
208 | | - " \n", |
209 | | - " # Check Redis connection\n", |
210 | | - " redis_available = redis_config.health_check()\n", |
211 | | - " print(f\"Redis connection: {'✅ Connected' if redis_available else '❌ Failed'}\")\n", |
212 | | - " \n", |
213 | | - " PACKAGE_AVAILABLE = True\n", |
214 | | - " print(\"✅ Redis Context Course package imported successfully\")\n", |
215 | | - " \n", |
216 | | - "except ImportError as e:\n", |
217 | | - " print(f\"⚠️ Package not available: {e}\")\n", |
218 | | - " print(\"📝 This is expected in CI environments. Creating mock objects for demonstration...\")\n", |
219 | | - " \n", |
220 | | - " # Create mock classes for demonstration\n", |
221 | | - " from enum import Enum\n", |
222 | | - " from typing import List, Optional\n", |
223 | | - " \n", |
224 | | - " class DifficultyLevel(Enum):\n", |
225 | | - " BEGINNER = \"beginner\"\n", |
226 | | - " INTERMEDIATE = \"intermediate\"\n", |
227 | | - " ADVANCED = \"advanced\"\n", |
228 | | - " \n", |
229 | | - " class CourseFormat(Enum):\n", |
230 | | - " ONLINE = \"online\"\n", |
231 | | - " IN_PERSON = \"in_person\"\n", |
232 | | - " HYBRID = \"hybrid\"\n", |
233 | | - " \n", |
234 | | - " class StudentProfile:\n", |
235 | | - " def __init__(self, name: str, email: str, major: str, year: int, \n", |
236 | | - " completed_courses: List[str], current_courses: List[str],\n", |
237 | | - " interests: List[str], preferred_format: CourseFormat,\n", |
238 | | - " preferred_difficulty: DifficultyLevel, max_credits_per_semester: int):\n", |
239 | | - " self.name = name\n", |
240 | | - " self.email = email\n", |
241 | | - " self.major = major\n", |
242 | | - " self.year = year\n", |
243 | | - " self.completed_courses = completed_courses\n", |
244 | | - " self.current_courses = current_courses\n", |
245 | | - " self.interests = interests\n", |
246 | | - " self.preferred_format = preferred_format\n", |
247 | | - " self.preferred_difficulty = preferred_difficulty\n", |
248 | | - " self.max_credits_per_semester = max_credits_per_semester\n", |
249 | | - " \n", |
250 | | - " class MemoryManager:\n", |
251 | | - " def __init__(self, student_id: str):\n", |
252 | | - " self.student_id = student_id\n", |
253 | | - " print(f\"📝 Mock MemoryManager created for {student_id}\")\n", |
254 | | - " \n", |
255 | | - " async def store_preference(self, content: str, context: str):\n", |
256 | | - " return \"mock-pref-id-12345\"\n", |
257 | | - " \n", |
258 | | - " async def store_goal(self, content: str, context: str):\n", |
259 | | - " return \"mock-goal-id-67890\"\n", |
260 | | - " \n", |
261 | | - " async def store_memory(self, content: str, memory_type: str, importance: float = 0.5):\n", |
262 | | - " return \"mock-memory-id-abcde\"\n", |
263 | | - " \n", |
264 | | - " async def retrieve_memories(self, query: str, limit: int = 5):\n", |
265 | | - " # Return mock memories\n", |
266 | | - " class MockMemory:\n", |
267 | | - " def __init__(self, content: str, memory_type: str):\n", |
268 | | - " self.content = content\n", |
269 | | - " self.memory_type = memory_type\n", |
270 | | - " \n", |
271 | | - " return [\n", |
272 | | - " MockMemory(\"Student prefers online courses due to work schedule\", \"preference\"),\n", |
273 | | - " MockMemory(\"Goal: Specialize in machine learning and AI\", \"goal\"),\n", |
274 | | - " MockMemory(\"Strong in programming, struggled with calculus\", \"academic_performance\")\n", |
275 | | - " ]\n", |
276 | | - " \n", |
277 | | - " async def get_student_context(self, query: str):\n", |
278 | | - " return {\n", |
279 | | - " \"preferences\": [\"online courses\", \"flexible schedule\"],\n", |
280 | | - " \"goals\": [\"machine learning specialization\"],\n", |
281 | | - " \"academic_history\": [\"strong programming background\"]\n", |
282 | | - " }\n", |
283 | | - " \n", |
284 | | - " PACKAGE_AVAILABLE = False\n", |
285 | | - " redis_available = False\n", |
286 | | - " print(\"✅ Mock objects created for demonstration\")\n", |
287 | | - "\n", |
288 | | - "except Exception as e:\n", |
289 | | - " print(f\"❌ Unexpected error: {e}\")\n", |
290 | | - " PACKAGE_AVAILABLE = False\n", |
291 | | - " redis_available = False" |
| 193 | + "# Import the Redis Context Course components\n", |
| 194 | + "from redis_context_course.models import Course, StudentProfile, DifficultyLevel, CourseFormat\n", |
| 195 | + "from redis_context_course.memory import MemoryManager\n", |
| 196 | + "from redis_context_course.course_manager import CourseManager\n", |
| 197 | + "from redis_context_course.redis_config import redis_config\n", |
| 198 | + "\n", |
| 199 | + "# Check Redis connection\n", |
| 200 | + "redis_available = redis_config.health_check()\n", |
| 201 | + "print(f\"Redis connection: {'✅ Connected' if redis_available else '❌ Failed'}\")\n", |
| 202 | + "print(\"✅ Redis Context Course package imported successfully\")" |
292 | 203 | ] |
293 | 204 | }, |
294 | 205 | { |
|
353 | 264 | "metadata": {}, |
354 | 265 | "outputs": [], |
355 | 266 | "source": [ |
356 | | - "# Check if classes are available (from previous import cell)\n", |
357 | | - "if 'StudentProfile' not in globals():\n", |
358 | | - " print(\"⚠️ Classes not available. Please run the import cell above first.\")\n", |
359 | | - " print(\"📝 Creating minimal mock classes for demonstration...\")\n", |
360 | | - " \n", |
361 | | - " from enum import Enum\n", |
362 | | - " from typing import List\n", |
363 | | - " \n", |
364 | | - " class DifficultyLevel(Enum):\n", |
365 | | - " BEGINNER = \"beginner\"\n", |
366 | | - " INTERMEDIATE = \"intermediate\"\n", |
367 | | - " ADVANCED = \"advanced\"\n", |
368 | | - " \n", |
369 | | - " class CourseFormat(Enum):\n", |
370 | | - " ONLINE = \"online\"\n", |
371 | | - " IN_PERSON = \"in_person\"\n", |
372 | | - " HYBRID = \"hybrid\"\n", |
373 | | - " \n", |
374 | | - " class StudentProfile:\n", |
375 | | - " def __init__(self, name: str, email: str, major: str, year: int, \n", |
376 | | - " completed_courses: List[str], current_courses: List[str],\n", |
377 | | - " interests: List[str], preferred_format: CourseFormat,\n", |
378 | | - " preferred_difficulty: DifficultyLevel, max_credits_per_semester: int):\n", |
379 | | - " self.name = name\n", |
380 | | - " self.email = email\n", |
381 | | - " self.major = major\n", |
382 | | - " self.year = year\n", |
383 | | - " self.completed_courses = completed_courses\n", |
384 | | - " self.current_courses = current_courses\n", |
385 | | - " self.interests = interests\n", |
386 | | - " self.preferred_format = preferred_format\n", |
387 | | - " self.preferred_difficulty = preferred_difficulty\n", |
388 | | - " self.max_credits_per_semester = max_credits_per_semester\n", |
389 | | - "\n", |
390 | 267 | "# Example student profile - user context\n", |
391 | 268 | "student = StudentProfile(\n", |
392 | 269 | " name=\"Alex Johnson\",\n", |
|
564 | 441 | "- **Historical context**: What has been learned over time\n", |
565 | 442 | "\n", |
566 | 443 | "### 2. **Memory is Essential**\n", |
567 | | - "- **Short-term memory**: Maintains conversation flow\n", |
| 444 | + "- **Working memory**: Maintains conversation flow\n", |
568 | 445 | "- **Long-term memory**: Enables learning and personalization\n", |
569 | 446 | "- **Semantic memory**: Allows intelligent retrieval of relevant information\n", |
570 | 447 | "\n", |
|
0 commit comments