MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / learn_from_message

Method learn_from_message

core/preferences.py:355–378  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers

nothing calls this directly

Calls 3

_update_preferenceMethod · 0.95
infoFunction · 0.90
searchMethod · 0.45

Tested by

no test coverage detected