Code
mem-redis-memory.py
Usage
1
Set up your virtual environment
2
Set environment variables
3
Install dependencies
4
Run Redis
5
Run Example
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Store user memories in Redis by passing RedisDb as the agent’s database.
from agno.agent import Agent
from agno.db.redis import RedisDb
# Setup Redis
# Initialize Redis db (use the right db_url for your setup)
db = RedisDb(db_url="redis://localhost:6379")
# Create agent with Redis db
agent = Agent(
db=db,
update_memory_on_run=True,
)
agent.print_response("My name is John Doe and I like to play basketball on the weekends.")
agent.print_response("What do I do on weekends?")
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Set environment variables
export OPENAI_API_KEY=xxx
Install dependencies
uv pip install -U agno openai redis
Run Redis
docker run --name my-redis -p 6379:6379 -d redis
Run Example
python mem-redis-memory.py
python mem-redis-memory.py
Was this page helpful?