Memory behaviour (fnord v0.8.88)
View SourceSummary
Callbacks
Returns true if a memory with the given title exists in the impl's storage.
Deletes the given memory from the impl's storage. The impl is responsible
for locking any shared resources and ensuring atomic delete behavior. Expects
an :error tuple if the memory does not exist.
Performs any necessary one-time initialization for the impl's storage. For
example, creating directories, loading currently select project from
Services.Globals, etc.
Returns true if this memory implementation is available in the current context. For example, project memory requires a selected project, and session memory requires an active conversation.
Returns a list of all memory titles available in the impl's storage. Ordering is not guaranteed.
Reads and returns the memory with the given title from the impl's storage.
The impl is responsible for ensuring that the returned memory is in the
correct structural format, including atomic keys (e.g. not strings if
unmarshalling JSON from disk).
Saves the given memory to the impl's storage. The impl is responsible for
locking any shared resources and ensuring atomic write behavior. It is
expected that the title of the memory is unique, and any existing memory
with the same title will be overwritten.
Functions
A title is unique within the given scope if no existing memory with the
same title exists.
A title is valid if it is non-empty, does not contain more than one non-word character in a row (which would lead to either multiple hyphens in the slug or cases where multiple titles map to the same slug), and does not start or end with a non-word character.
Serializes the given memory to a JSON binary.
Creates a new Memory struct from the given map. Expects keys to be atoms.
Returns a Memory.t.
Converts a slug back to a title by replacing hyphens with spaces and capitalizing each word.
Converts a title to a slug by lowercasing it, replacing non-word characters with hyphens, and trimming leading/trailing hyphens.
Deserializes the given JSON binary to a Memory struct.
Types
Callbacks
Returns true if a memory with the given title exists in the impl's storage.
Deletes the given memory from the impl's storage. The impl is responsible
for locking any shared resources and ensuring atomic delete behavior. Expects
an :error tuple if the memory does not exist.
@callback init() :: :ok | {:error, term()}
Performs any necessary one-time initialization for the impl's storage. For
example, creating directories, loading currently select project from
Services.Globals, etc.
@callback is_available?() :: boolean()
Returns true if this memory implementation is available in the current context. For example, project memory requires a selected project, and session memory requires an active conversation.
Returns a list of all memory titles available in the impl's storage. Ordering is not guaranteed.
Reads and returns the memory with the given title from the impl's storage.
The impl is responsible for ensuring that the returned memory is in the
correct structural format, including atomic keys (e.g. not strings if
unmarshalling JSON from disk).
Saves the given memory to the impl's storage. The impl is responsible for
locking any shared resources and ensuring atomic write behavior. It is
expected that the title of the memory is unique, and any existing memory
with the same title will be overwritten.
Functions
@spec init() :: :ok | {:error, term()}
@spec is_available?() :: boolean()
A title is unique within the given scope if no existing memory with the
same title exists.
A title is valid if it is non-empty, does not contain more than one non-word character in a row (which would lead to either multiple hyphens in the slug or cases where multiple titles map to the same slug), and does not start or end with a non-word character.
Serializes the given memory to a JSON binary.
Creates a new Memory struct from the given map. Expects keys to be atoms.
Returns a Memory.t.
@spec search(binary(), non_neg_integer()) :: {:ok, [{t(), float()}]} | {:error, term()}
Converts a slug back to a title by replacing hyphens with spaces and capitalizing each word.
Converts a title to a slug by lowercasing it, replacing non-word characters with hyphens, and trimming leading/trailing hyphens.
Deserializes the given JSON binary to a Memory struct.