Skip to main content

Module memory_extractor

Module memory_extractor 

Source
Expand description

B4 (v0.22.4): LLM-backed semantic-memory extractor turning a completed turn into durable lc_memory::MemoryItems. B4 (v0.22.4): LLM-backed lc_memory::MemoryExtractor.

LlmMemoryExtractor asks any lc_core::language_models::BaseChatModel to distill a completed turn into durable facts as a strict JSON array, then converts the reply into lc_memory::MemoryItems for the two-tier semantic memory (see lc_memory::semantic).

Design notes:

  • Parsing is tolerant, extraction is lossy-safe. Fenced code blocks and prose around the JSON are stripped via lc_core::json_parse::parse_llm_json; both a bare array and an object envelope ({"memories": [...]}) are accepted; malformed individual entries are skipped, never fatal to the turn.
  • The model chooses importance. The prompt requests a [0, 1] float; missing values default to 0.5, out-of-range values are clamped by the store.
  • Keys are stable. A missing key is derived from the fact text itself (normalized, truncated), so the same fact extracted twice updates one entry instead of duplicating.
  • No network in tests. The extractor is generic over the model; the module tests use a fixed-reply fake.

Structs§

LlmMemoryExtractor
lc_memory::MemoryExtractor backed by any chat model.