turso_managed.py
1 """ 2 Turso/libSQL Persistence Example. 3 4 Turso provides SQLite-at-the-edge with automatic sync and scale-to-zero. 5 6 Setup: 7 1. Create free Turso database at https://turso.tech 8 2. Run: turso db tokens create <db-name> 9 3. Set env vars: 10 export TURSO_DATABASE_URL="libsql://mydb-user.turso.io" 11 export TURSO_AUTH_TOKEN="eyJ..." 12 4. pip install praisonai[turso] 13 """ 14 15 import os 16 from praisonaiagents import Agent 17 18 agent = Agent( 19 name="Turso Agent", 20 instructions="You are a helpful assistant.", 21 db={ 22 "database_url": os.getenv("TURSO_DATABASE_URL"), 23 "auth_token": os.getenv("TURSO_AUTH_TOKEN"), 24 }, 25 session_id="turso-demo-session", 26 ) 27 28 result = agent.start("What is edge computing? Explain in 2 sentences.") 29 print(result)