Learn preferences from a natural language user message. Detects phrases like "always use pytest", "I prefer httpx", "don't use print", "add type hints", etc. Args: message: User's message text Returns: Dict of category -> value for
(self, message: str)
| 353 | return dict(all_detected) |
| 354 | |
| 355 | def learn_from_message(self, message: str) -> Dict[str, str]: |
| 356 | """ |
| 357 | Learn preferences from a natural language user message. |
| 358 | |
| 359 | Detects phrases like "always use pytest", "I prefer httpx", |
| 360 | "don't use print", "add type hints", etc. |
| 361 | |
| 362 | Args: |
| 363 | message: User's message text |
| 364 | |
| 365 | Returns: |
| 366 | Dict of category -> value for any preferences detected |
| 367 | """ |
| 368 | found = {} |
| 369 | msg_lower = message.lower() |
| 370 | for pattern, category, value_spec in PreferenceManager.NL_PATTERNS: |
| 371 | m = re.search(pattern, msg_lower) |
| 372 | if m: |
| 373 | value = m.group(value_spec) if isinstance(value_spec, int) else value_spec |
| 374 | if value: |
| 375 | self._update_preference(category, value, confidence=1.0) |
| 376 | found[category] = value |
| 377 | info(f"Learned preference from message: {category} = {value}") |
| 378 | return found |
| 379 | |
| 380 | def _update_preference(self, key: str, value: str, confidence: float = 0.3): |
| 381 | """ |
nothing calls this directly
no test coverage detected