Lux.Memory behaviour (Lux v0.5.0)
View SourceCore memory functionality for Lux agents and components.
There are two ways to use memory:
Named memories (defined as modules): defmodule MyAgentMemory do use Lux.Memory,
backend: Lux.Memory.ETS, name: :my_agent_memory
end
Dynamic memories: {:ok, memory} = Lux.Memory.initialize(backend: Lux.Memory.ETS)
Summary
Types
Callbacks
@callback add(memory_ref(), content :: term(), type :: memory_type(), metadata :: map()) :: {:ok, memory_entry()} | {:error, term()}
@callback initialize(keyword()) :: {:ok, memory_ref()} | {:error, term()}
@callback recent(memory_ref(), n :: pos_integer()) :: {:ok, [memory_entry()]} | {:error, term()}
@callback search(memory_ref(), query :: String.t()) :: {:ok, [memory_entry()]} | {:error, term()}
@callback window(memory_ref(), start_time :: DateTime.t(), end_time :: DateTime.t()) :: {:ok, [memory_entry()]} | {:error, term()}