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

Copy Markdown View Source

Behaviour for storage backends.

The base behaviour defines conversation and message callbacks that every adapter must implement. Sub-behaviours (FactStore, ProfileStore) are optional — adapters implement them to support long-term memory.

Summary

Callbacks

add_message(conversation_id, t, opts)

@callback add_message(
  conversation_id :: String.t(),
  PhoenixAI.Store.Message.t(),
  opts :: keyword()
) ::
  {:ok, PhoenixAI.Store.Message.t()} | {:error, term()}

conversation_exists?(id, opts)

@callback conversation_exists?(id :: String.t(), opts :: keyword()) ::
  {:ok, boolean()} | {:error, term()}

count_conversations(filters, opts)

@callback count_conversations(filters :: keyword(), opts :: keyword()) ::
  {:ok, non_neg_integer()} | {:error, term()}

delete_conversation(id, opts)

@callback delete_conversation(id :: String.t(), opts :: keyword()) ::
  :ok | {:error, :not_found | term()}

get_messages(conversation_id, opts)

@callback get_messages(conversation_id :: String.t(), opts :: keyword()) ::
  {:ok, [PhoenixAI.Store.Message.t()]} | {:error, term()}

list_conversations(filters, opts)

@callback list_conversations(filters :: keyword(), opts :: keyword()) ::
  {:ok, [PhoenixAI.Store.Conversation.t()]} | {:error, term()}

load_conversation(id, opts)

@callback load_conversation(id :: String.t(), opts :: keyword()) ::
  {:ok, PhoenixAI.Store.Conversation.t()} | {:error, :not_found | term()}

save_conversation(t, opts)

@callback save_conversation(PhoenixAI.Store.Conversation.t(), opts :: keyword()) ::
  {:ok, PhoenixAI.Store.Conversation.t()} | {:error, term()}