forked from 0xWheatyz/SPARC
feat(backend): add response caching and user management
Replace USE_DATABASE toggle with USE_CACHE for smarter LLM response handling: - Add prompt hashing for efficient cache lookups - Cache API responses in database to reduce token usage - Always store responses for analytics (cache or fresh) Add user authentication infrastructure: - User table with bcrypt password hashing - CRUD operations for user management - Role-based access control (admin/user) Dependencies: add bcrypt and PyJWT for auth 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+9
-4
@@ -13,10 +13,15 @@ api_key = os.getenv("API_KEY")
|
||||
# OpenRouter API key for LLM analysis
|
||||
openrouter_api_key = os.getenv("OPENROUTER_API_KEY")
|
||||
|
||||
# Database configuration
|
||||
# Database configuration - all messages are stored in the database
|
||||
# The database serves as both a persistent store and a cache layer
|
||||
database_url = os.getenv("DATABASE_URL", "postgresql://postgres:postgres@localhost:5432/sparc")
|
||||
|
||||
# Toggle between database mode and API mode
|
||||
# When True: stores all messages in database instead of sending to OpenRouter
|
||||
# When False: sends messages to OpenRouter API as normal
|
||||
# Cache configuration
|
||||
# When enabled (default), the system checks the database for cached responses
|
||||
# before making API calls, saving tokens and reducing latency
|
||||
use_cache = os.getenv("USE_CACHE", "true").lower() in ("true", "1", "yes")
|
||||
|
||||
# Legacy compatibility - USE_DATABASE is deprecated, database is always used
|
||||
# This variable is kept for backwards compatibility but has no effect
|
||||
use_database = os.getenv("USE_DATABASE", "false").lower() in ("true", "1", "yes")
|
||||
|
||||
Reference in New Issue
Block a user