PhoenixAI.Store.Adapter.FactStore behaviour (PhoenixAI.Store v0.1.0)

Copy Markdown View Source

Sub-behaviour for adapters that support long-term memory fact storage.

Adapters implementing this behaviour can store, retrieve, and delete per-user key-value facts. save_fact/2 uses upsert semantics — writing to the same {user_id, key} overwrites the previous value.

Summary

Callbacks

count_facts(user_id, keyword)

@callback count_facts(
  user_id :: String.t(),
  keyword()
) :: {:ok, non_neg_integer()} | {:error, term()}

delete_fact(user_id, key, keyword)

@callback delete_fact(user_id :: String.t(), key :: String.t(), keyword()) ::
  :ok | {:error, term()}

get_facts(user_id, keyword)

@callback get_facts(
  user_id :: String.t(),
  keyword()
) :: {:ok, [PhoenixAI.Store.LongTermMemory.Fact.t()]} | {:error, term()}

save_fact(t, keyword)

@callback save_fact(
  PhoenixAI.Store.LongTermMemory.Fact.t(),
  keyword()
) :: {:ok, PhoenixAI.Store.LongTermMemory.Fact.t()} | {:error, term()}