90f9cfc826
The SERP query had a frozen date range (Oct-Nov 2025) that returned stale patents. Now computes a rolling window from config (PATENT_SEARCH_DAYS, default 90 days). Also adds filesystem-level PDF caching to skip re-downloading existing patent PDFs, and adds PATENT_THREAD_WORKERS config for upcoming parallel processing.
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
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 - 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")
|
|
|
|
# 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")
|
|
|
|
# Patent search configuration
|
|
patent_search_days = int(os.getenv("PATENT_SEARCH_DAYS", "90"))
|
|
patent_thread_workers = int(os.getenv("PATENT_THREAD_WORKERS", "5"))
|
|
|
|
# Root path for running behind a reverse proxy (e.g., "/api" when served at /api/)
|
|
# This ensures OpenAPI docs work correctly when accessed via the proxy
|
|
root_path = os.getenv("ROOT_PATH", "")
|