Skip to content

mempalace.general_extractor

Source: mempalace/general_extractor.py

general_extractor.py — Extract 5 types of memories from text.

Types:

  1. DECISIONS — "we went with X because Y", choices made
  2. PREFERENCES — "always use X", "never do Y", "I prefer Z"
  3. MILESTONES — breakthroughs, things that finally worked
  4. PROBLEMS — what broke, what fixed it, root causes
  5. EMOTIONAL — feelings, vulnerability, relationships

No LLM required. Pure keyword/pattern heuristics. No external dependencies on palace.py, dialect.py, or layers.py.

Usage: from general_extractor import extract_memories

chunks = extract_memories(text)
# [{"content": "...", "memory_type": "decision", "chunk_index": 0}, ...]

Functions

extract_memories

python
def extract_memories(text: str, min_confidence: float = 0.3, chunk_size: int = DEFAULT_CHUNK_SIZE) -> List[Dict]

Extract memories from a text string.

Args: text: The text to extract from (any format). min_confidence: Minimum confidence threshold (0.0-1.0). chunk_size: Per-memory character cap. Segments exceeding this size are sliced verbatim into multiple memories that share the same memory_type. Caller (typically mine_convos) should pass MempalaceConfig.chunk_size so config-driven sizing reaches this path; the default matches the module-level CHUNK_SIZE in convo_miner.py.

Returns: List of dicts: {"content": str, "memory_type": str, "chunk_index": int}

Released under the MIT License.