Class: RCrewAI::Memory::EntityMemory

Inherits:
BaseMemory show all
Defined in:
lib/rcrewai/memory/entity_memory.rb

Overview

Facts about entities (people, systems, concepts) accumulated from work. Entities are extracted heuristically (capitalized tokens / acronyms); an LLM-backed extractor can be swapped in later.

Constant Summary collapse

COMMON =

Skip sentence-initial common words that happen to be capitalized.

%w[The A An I In On At To For Of With By And Or But It This That Who Where When].freeze

Instance Method Summary collapse

Methods inherited from BaseMemory

#clear!, #count, #recall, #record

Constructor Details

#initialize(scope:, embedder: nil, store: nil, limit: nil, extractor: nil) ⇒ EntityMemory

Returns a new instance of EntityMemory.



14
15
16
17
18
# File 'lib/rcrewai/memory/entity_memory.rb', line 14

def initialize(scope:, embedder: nil, store: nil, limit: nil, extractor: nil)
  super(scope: scope, embedder: embedder, store: store, limit: limit)
  @extractor = extractor
  @entities = []
end

Instance Method Details

#entitiesObject



27
28
29
# File 'lib/rcrewai/memory/entity_memory.rb', line 27

def entities
  @entities.uniq
end

#observe(text) ⇒ Object

Records a full observation and indexes the entities it mentions.



21
22
23
24
25
# File 'lib/rcrewai/memory/entity_memory.rb', line 21

def observe(text)
  found = extract_entities(text)
  @entities.concat(found)
  add(text, { 'entities' => found })
end