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

Copy Markdown View Source

Sub-behaviour for adapters that support token usage aggregation.

Used by the TokenBudget guardrail policy to efficiently query accumulated token counts without loading full message lists.

Summary

Callbacks

sum_conversation_tokens(conversation_id, keyword)

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

sum_user_tokens(user_id, keyword)

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