Nous.Memory.Store behaviour (nous v0.13.3)

View Source

Storage behaviour for memory backends.

All search/list callbacks accept a :scope option (map of scoping fields to filter by).

Summary

Callbacks

delete(state, id)

@callback delete(state :: term(), id :: String.t()) :: {:ok, term()} | {:error, term()}

fetch(state, id)

@callback fetch(state :: term(), id :: String.t()) ::
  {:ok, Nous.Memory.Entry.t()} | {:error, :not_found}

init(opts)

@callback init(opts :: keyword()) :: {:ok, term()} | {:error, term()}

list(state, opts)

@callback list(state :: term(), opts :: keyword()) :: {:ok, [Nous.Memory.Entry.t()]}

search_text(state, query, opts)

@callback search_text(state :: term(), query :: String.t(), opts :: keyword()) ::
  {:ok, [{Nous.Memory.Entry.t(), float()}]}

search_vector(state, embedding, opts)

(optional)
@callback search_vector(state :: term(), embedding :: [float()], opts :: keyword()) ::
  {:ok, [{Nous.Memory.Entry.t(), float()}]}

store(state, entry)

@callback store(state :: term(), entry :: Nous.Memory.Entry.t()) ::
  {:ok, term()} | {:error, term()}

update(state, id, updates)

@callback update(state :: term(), id :: String.t(), updates :: map()) ::
  {:ok, term()} | {:error, term()}