""" Main application entry point for the Professional RAG Assistant. """ import os import sys import argparse import logging from pathlib import Path # Add src to path sys.path.append(str(Path(__file__).parent / "src")) sys.path.append(str(Path(__file__).parent / "ui")) from ui.main_interface import create_interface def setup_logging(): """Setup basic logging configuration.""" log_dir = Path("logs") log_dir.mkdir(exist_ok=True) logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', handlers=[ logging.FileHandler(log_dir / "app.log"), logging.StreamHandler() ] ) def main(): """Main application entry point.""" parser = argparse.ArgumentParser(description="Professional RAG Document Assistant") parser.add_argument( "--config", type=str, default=None, help="Path to configuration file (default: config.yaml or config-local.yaml)" ) parser.add_argument( "--host", type=str, default="0.0.0.0", help="Host to bind to (default: 0.0.0.0)" ) parser.add_argument( "--port", type=int, default=7860, help="Port to bind to (default: 7860)" ) parser.add_argument( "--share", action="store_true", help="Create a public Gradio link" ) parser.add_argument( "--debug", action="store_true", help="Enable debug mode" ) args = parser.parse_args() # Setup logging setup_logging() logger = logging.getLogger(__name__) logger.info("Starting Professional RAG Assistant...") logger.info(f"Configuration: {args.config}") logger.info(f"Host: {args.host}, Port: {args.port}") try: # Create interface interface = create_interface(config_path=args.config) # Launch interface logger.info("Launching Gradio interface...") interface.launch( server_name=args.host, server_port=args.port, share=args.share, debug=args.debug, show_error=True, inbrowser=False, # Don't auto-open browser in production favicon_path=None, app_kwargs={ "docs_url": None, # Disable FastAPI docs "redoc_url": None # Disable ReDoc } ) except KeyboardInterrupt: logger.info("Application stopped by user") except Exception as e: logger.error(f"Application failed to start: {e}", exc_info=True) sys.exit(1) if __name__ == "__main__": main()