PhoenixAI Store
Persistence, memory management, guardrails, cost tracking, and an audit event log for PhoenixAI conversations.
Features
- Conversation Persistence — ETS (in-memory) and Ecto (PostgreSQL/SQLite) adapters
- Memory Strategies — Sliding window, token-aware truncation, pinned messages
- Guardrails — Token budgets, cost budgets, and rate limiting before AI calls
- Cost Tracking — Per-conversation and per-user cost accumulation with Decimal precision
- Event Log — Append-only audit trail with cursor pagination and PII redaction
- Single-Function Pipeline —
converse/3handles load → memory → guardrails → AI → save → track
Installation
Add phoenix_ai_store to your list of dependencies in mix.exs:
def deps do
[
{:phoenix_ai_store, "~> 0.1.0"}
]
endQuick Start
# Add to your supervision tree
children = [
{PhoenixAI.Store, name: :my_store, adapter: PhoenixAI.Store.Adapters.ETS}
]
# Create a conversation
{:ok, conv} = PhoenixAI.Store.save_conversation(
%PhoenixAI.Store.Conversation{title: "My Chat"},
store: :my_store
)
# Run the full pipeline
{:ok, response} = PhoenixAI.Store.converse(
conv.id,
"Hello!",
provider: :openai,
model: "gpt-4o",
api_key: System.get_env("OPENAI_API_KEY"),
store: :my_store
)Documentation
- Getting Started — Installation and first conversation
- Adapters Guide — ETS vs Ecto, custom adapters
- Memory & Guardrails — Context window management
- Telemetry & Events — Automatic event capture
License
MIT — see LICENSE for details.