forked from 0xWheatyz/SPARC
44456cb073
Implements a database mode that stores LLM prompts and responses in PostgreSQL instead of making API calls. This enables: - Testing without consuming API credits - Collecting analytics on usage patterns - Development and debugging workflows Changes: - Added DatabaseClient class for PostgreSQL operations - Modified LLMAnalyzer to support database/API mode toggle - Added USE_DATABASE config flag to switch between modes - Included Docker Compose setup for PostgreSQL - Added utility scripts for database init and analytics viewing - Comprehensive documentation in DATABASE_MODE.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
23 lines
717 B
Python
23 lines
717 B
Python
"""Configuration and secrets management.
|
|
|
|
Loads environment variables from .env file for API keys and other secrets.
|
|
"""
|
|
from dotenv import load_dotenv
|
|
import os
|
|
|
|
load_dotenv()
|
|
|
|
# SerpAPI key for patent search
|
|
api_key = os.getenv("API_KEY")
|
|
|
|
# OpenRouter API key for LLM analysis
|
|
openrouter_api_key = os.getenv("OPENROUTER_API_KEY")
|
|
|
|
# Database configuration
|
|
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
|
|
use_database = os.getenv("USE_DATABASE", "false").lower() in ("true", "1", "yes")
|