""" Configuration settings for the application. """ import os from dotenv import load_dotenv # Load environment variables from .env file load_dotenv() class Config: """Base configuration.""" # Flask configuration SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-key-for-development-only') DEBUG = False TESTING = False # Database configuration SQLALCHEMY_DATABASE_URI = os.environ.get( 'DATABASE_URL', 'sqlite:///chatbot.db' ) SQLALCHEMY_TRACK_MODIFICATIONS = False INITIALIZE_DATABASE = os.environ.get('INITIALIZE_DATABASE', 'False').lower() == 'true' # Pinecone configuration PINECONE_API_KEY = os.environ.get('PINECONE_API_KEY', '') PINECONE_ENVIRONMENT = os.environ.get('PINECONE_ENVIRONMENT', '') PINECONE_INDEX_NAME = os.environ.get('PINECONE_INDEX_NAME', 'chatbot-index') # Model configuration DEFAULT_MODEL = os.environ.get('DEFAULT_MODEL', 'gpt-3.5-turbo') OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY', '') class DevelopmentConfig(Config): """Development configuration.""" DEBUG = True class TestingConfig(Config): """Testing configuration.""" TESTING = True SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:' class ProductionConfig(Config): """Production configuration.""" # Ensure all required environment variables are set in production @classmethod def init_app(cls, app): """Initialize production application.""" # Check for required environment variables required_vars = [ 'SECRET_KEY', 'DATABASE_URL', 'PINECONE_API_KEY', 'PINECONE_ENVIRONMENT', 'OPENAI_API_KEY' ] missing_vars = [var for var in required_vars if not os.environ.get(var)] if missing_vars: raise RuntimeError( f"Missing required environment variables: {', '.join(missing_vars)}" ) # Configuration dictionary config = { 'development': DevelopmentConfig, 'testing': TestingConfig, 'production': ProductionConfig, 'default': DevelopmentConfig }