""" Production Configuration for LightRAG System Database connections and performance settings for production deployment """ import os from dataclasses import dataclass from typing import List, Dict, Any @dataclass class DatabaseConfig: """Database connection configurations""" REDIS_URL: str = "redis://localhost:6379" NEO4J_URL: str = "bolt://localhost:7687" NEO4J_USERNAME: str = "neo4j" NEO4J_PASSWORD: str = "jleu1212" QDRANT_URL: str = "http://localhost:6333/" POSTGRES_URL: str = "postgresql://jleu3482:jleu1212@localhost:5432/rag_anything" @dataclass class ModelConfig: """AI Model configurations""" DEEPSEEK_API_KEY: str = "sk-55f6e57f1d834b0e93ceaf98cc2cb715" DEEPSEEK_BASE_URL: str = "https://api.deepseek.com/v1" OLLAMA_URL: str = "http://127.0.0.1:11434" SPACY_MODEL: str = "en_core_web_sm" RERANKER_ENABLED: bool = False @dataclass class PerformanceConfig: """Performance optimization settings""" USE_GPU: bool = True PARALLEL_PROCESSING: bool = True MAX_PARALLEL_INSERT: int = 4 CHUNK_SIZE: int = 1200 CHUNK_OVERLAP: int = 100 MAX_GRAPH_NODES: int = 1000 BATCH_SIZE: int = 32 @dataclass class DocumentProcessingConfig: """Document processing settings""" SUPPORTED_EXTENSIONS: List[str] = None OCR_LANGUAGES: List[str] = None OCR_ENGINE: str = "paddleocr" def __post_init__(self): if self.SUPPORTED_EXTENSIONS is None: self.SUPPORTED_EXTENSIONS = [ '.pdf', '.docx', '.doc', '.xlsx', '.xls', '.pptx', '.ppt', '.txt', '.csv', '.html', '.htm', '.md', '.jpg', '.jpeg', '.png', '.tiff', '.bmp', '.gif' ] if self.OCR_LANGUAGES is None: self.OCR_LANGUAGES = ['en', 'ch'] @dataclass class ServerConfig: """Server configuration""" PORT: int = 3015 HOST: str = "0.0.0.0" API_KEY: str = "lightrag-test-key" DEBUG: bool = False @dataclass class ProductionConfig: """Main production configuration""" databases: DatabaseConfig = None models: ModelConfig = None performance: PerformanceConfig = None document_processing: DocumentProcessingConfig = None server: ServerConfig = None def __post_init__(self): if self.databases is None: self.databases = DatabaseConfig() if self.models is None: self.models = ModelConfig() if self.performance is None: self.performance = PerformanceConfig() if self.document_processing is None: self.document_processing = DocumentProcessingConfig() if self.server is None: self.server = ServerConfig() # Global configuration instance _config_instance = None def get_config() -> ProductionConfig: """Get singleton configuration instance""" global _config_instance if _config_instance is None: _config_instance = ProductionConfig() return _config_instance def update_config(**kwargs) -> ProductionConfig: """Update configuration with new values""" config = get_config() for key, value in kwargs.items(): if hasattr(config, key): setattr(config, key, value) elif hasattr(config.databases, key): setattr(config.databases, key, value) elif hasattr(config.models, key): setattr(config.models, key, value) elif hasattr(config.performance, key): setattr(config.performance, key, value) elif hasattr(config.document_processing, key): setattr(config.document_processing, key, value) elif hasattr(config.server, key): setattr(config.server, key, value) return config # Export configuration config = get_config()