Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Persistence Module
The Persistence module provides database adapters and session management for storing agent conversations, runs, and traces.
Installation
pip install praisonai
# For specific database support
pip install "praisonai[postgres]"
pip install "praisonai[redis]"
Quick Start
The recommended way to enable persistence is via the memory={} parameter:
from praisonaiagents import Agent
agent = Agent(
name="Assistant",
instructions="You are helpful.",
memory={
"db": "postgresql://localhost/mydb",
"session_id": "my-session"
}
)
response = agent.start("Hello!")
Supported Databases
Conversation Stores
| Database | Install | URL Format |
|---|
| PostgreSQL | pip install "praisonai[postgres]" | postgresql://user:pass@host/db |
| MySQL | pip install "praisonai[mysql]" | mysql://user:pass@host/db |
| SQLite | Built-in | sqlite:///path/to/db.sqlite |
| JSON | Built-in | json:///path/to/data.json |
Knowledge Stores (Vector)
| Database | Install |
|---|
| Qdrant | pip install "praisonai[qdrant]" |
| Chroma | pip install "praisonai[chroma]" |
| Pinecone | pip install "praisonai[pinecone]" |
| PGVector | pip install "praisonai[pgvector]" |
State Stores
| Database | Install |
|---|
| Redis | pip install "praisonai[redis]" |
| MongoDB | pip install "praisonai[mongodb]" |
Database Examples
PostgreSQL
from praisonaiagents import Agent
agent = Agent(
name="Assistant",
memory={
"db": "postgresql://user:pass@localhost/mydb",
"session_id": "user-123"
}
)
SQLite
from praisonaiagents import Agent
agent = Agent(
name="Assistant",
memory={
"db": "sqlite:///./agent.db",
"session_id": "local-session"
}
)
Redis
from praisonaiagents import Agent
agent = Agent(
name="Assistant",
memory={
"backend": "redis",
"db": "redis://localhost:6379",
"session_id": "redis-session"
}
)
Session Management
Sessions allow you to maintain conversational context:
from praisonaiagents import Agent
# Create agent with session
agent = Agent(
name="Assistant",
memory={"db": "sqlite:///data.db", "session_id": "user-123"}
)
# Conversations persist across runs
response1 = agent.start("Remember my name is Alice")
# Later...
response2 = agent.start("What's my name?") # Remembers "Alice"
Data Models
DbMessage
Stored message format:
{
"id": "msg-uuid",
"session_id": "session-123",
"agent_id": "agent-name",
"role": "user", # or "assistant"
"content": "Message content",
"timestamp": "2024-01-01T00:00:00Z"
}
DbRun
Execution run record:
{
"id": "run-uuid",
"session_id": "session-123",
"agent_id": "agent-name",
"status": "completed",
"started_at": "2024-01-01T00:00:00Z",
"completed_at": "2024-01-01T00:00:01Z"
}
Tool execution record:
{
"id": "tool-uuid",
"run_id": "run-uuid",
"tool_name": "search",
"arguments": {"query": "AI news"},
"result": "Search results...",
"timestamp": "2024-01-01T00:00:00Z"
}
See Also