Unified learning manager for Codey-v2. Coordinates learning across: - Preferences (user style) - Errors (what went wrong + fixes) - Strategies (what recovery approaches work) Usage: learning = get_learning_manager() # Learn from file learning.learn
| 21 | |
| 22 | |
| 23 | class LearningManager: |
| 24 | """ |
| 25 | Unified learning manager for Codey-v2. |
| 26 | |
| 27 | Coordinates learning across: |
| 28 | - Preferences (user style) |
| 29 | - Errors (what went wrong + fixes) |
| 30 | - Strategies (what recovery approaches work) |
| 31 | |
| 32 | Usage: |
| 33 | learning = get_learning_manager() |
| 34 | |
| 35 | # Learn from file |
| 36 | learning.learn_from_file("test_auth.py", content) |
| 37 | |
| 38 | # Record error and fix |
| 39 | learning.record_error("ModuleNotFoundError", "...", fix="pip install flask") |
| 40 | |
| 41 | # Get best strategy |
| 42 | strategy = learning.get_best_strategy("ModuleNotFoundError") |
| 43 | |
| 44 | # Get user preferences |
| 45 | test_framework = learning.get_preference("test_framework") |
| 46 | """ |
| 47 | |
| 48 | def __init__(self): |
| 49 | self.preferences: PreferenceManager = get_preferences() |
| 50 | self.error_db: ErrorDatabase = get_error_database() |
| 51 | self.strategy_tracker: StrategyTracker = get_strategy_tracker() |
| 52 | |
| 53 | def learn_from_file(self, path: str, content: str) -> Dict[str, str]: |
| 54 | """ |
| 55 | Learn preferences from a file. |
| 56 | |
| 57 | Args: |
| 58 | path: File path |
| 59 | content: File content |
| 60 | |
| 61 | Returns: |
| 62 | Detected preferences |
| 63 | """ |
| 64 | return self.preferences.learn_from_file(path, content) |
| 65 | |
| 66 | def learn_from_files(self, files: List[tuple]) -> Dict[str, List[str]]: |
| 67 | """ |
| 68 | Learn preferences from multiple files. |
| 69 | |
| 70 | Args: |
| 71 | files: List of (path, content) tuples |
| 72 | |
| 73 | Returns: |
| 74 | All detected preferences |
| 75 | """ |
| 76 | return self.preferences.learn_from_files(files) |
| 77 | |
| 78 | def record_error(self, error_type: str, error_message: str, |
| 79 | context: Dict = None) -> str: |
| 80 | """ |
no outgoing calls