#!/usr/bin/env python3 """ DeepCode - AI Research Engine Launcher ๐Ÿงฌ Next-Generation AI Research Automation Platform โšก Transform research papers into working code automatically """ import os import sys import subprocess from pathlib import Path def check_dependencies(): """Check if necessary dependencies are installed""" import importlib.util print("๐Ÿ” Checking dependencies...") missing_deps = [] missing_system_deps = [] # Check Streamlit availability if importlib.util.find_spec("streamlit") is not None: print("โœ… Streamlit is installed") else: missing_deps.append("streamlit>=1.28.0") # Check PyYAML availability if importlib.util.find_spec("yaml") is not None: print("โœ… PyYAML is installed") else: missing_deps.append("pyyaml") # Check asyncio availability if importlib.util.find_spec("asyncio") is not None: print("โœ… Asyncio is available") else: missing_deps.append("asyncio") # Check PDF conversion dependencies if importlib.util.find_spec("reportlab") is not None: print("โœ… ReportLab is installed (for text-to-PDF conversion)") else: missing_deps.append("reportlab") print("โš ๏ธ ReportLab not found (text files won't convert to PDF)") # Check LibreOffice for Office document conversion try: import subprocess import platform subprocess_kwargs = { "capture_output": True, "text": True, "timeout": 5, } if platform.system() == "Windows": subprocess_kwargs["creationflags"] = 0x08000000 # Hide console window # Try different LibreOffice commands libreoffice_found = False for cmd in ["libreoffice", "soffice"]: try: result = subprocess.run([cmd, "--version"], **subprocess_kwargs) if result.returncode == 0: print( "โœ… LibreOffice is installed (for Office document conversion)" ) libreoffice_found = True break except ( subprocess.CalledProcessError, FileNotFoundError, subprocess.TimeoutExpired, ): continue if not libreoffice_found: missing_system_deps.append("LibreOffice") print("โš ๏ธ LibreOffice not found (Office documents won't convert to PDF)") except Exception: missing_system_deps.append("LibreOffice") print("โš ๏ธ Could not check LibreOffice installation") # Display missing dependencies if missing_deps or missing_system_deps: print("\n๐Ÿ“‹ Dependency Status:") if missing_deps: print("โŒ Missing Python dependencies:") for dep in missing_deps: print(f" - {dep}") print(f"\nInstall with: pip install {' '.join(missing_deps)}") if missing_system_deps: print("\nโš ๏ธ Missing system dependencies (optional for full functionality):") for dep in missing_system_deps: print(f" - {dep}") print("\nInstall LibreOffice:") print(" - Windows: Download from https://www.libreoffice.org/") print(" - macOS: brew install --cask libreoffice") print(" - Ubuntu/Debian: sudo apt-get install libreoffice") # Only fail if critical Python dependencies are missing if missing_deps: return False else: print("\nโœ… Core dependencies satisfied (optional dependencies missing)") else: print("โœ… All dependencies satisfied") return True def cleanup_cache(): """Clean up Python cache files""" try: print("๐Ÿงน Cleaning up cache files...") # Clean up __pycache__ directories os.system('find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null') # Clean up .pyc files os.system('find . -name "*.pyc" -delete 2>/dev/null') print("โœ… Cache cleanup completed") except Exception as e: print(f"โš ๏ธ Cache cleanup failed: {e}") def print_banner(): """Display startup banner""" banner = """ โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•— โ•‘ โ•‘ โ•‘ ๐Ÿงฌ DeepCode - AI Research Engine โ•‘ โ•‘ โ•‘ โ•‘ โšก NEURAL โ€ข AUTONOMOUS โ€ข REVOLUTIONARY โšก โ•‘ โ•‘ โ•‘ โ•‘ Transform research papers into working code โ•‘ โ•‘ Next-generation AI automation platform โ•‘ โ•‘ โ•‘ โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• """ print(banner) def main(): """Main function""" print_banner() # Check dependencies if not check_dependencies(): print("\n๐Ÿšจ Please install missing dependencies and try again.") sys.exit(1) # Get current script directory current_dir = Path(__file__).parent streamlit_app_path = current_dir / "ui" / "streamlit_app.py" # Check if streamlit_app.py exists if not streamlit_app_path.exists(): print(f"โŒ UI application file not found: {streamlit_app_path}") print("Please ensure the ui/streamlit_app.py file exists.") sys.exit(1) print(f"\n๐Ÿ“ UI App location: {streamlit_app_path}") print("๐ŸŒ Starting DeepCode web interface...") print("๐Ÿš€ Launching on http://localhost:8501") print("=" * 70) print("๐Ÿ’ก Tip: Keep this terminal open while using the application") print("๐Ÿ›‘ Press Ctrl+C to stop the server") print("=" * 70) # Launch Streamlit application try: cmd = [ sys.executable, "-m", "streamlit", "run", str(streamlit_app_path), "--server.port", "8501", "--server.address", "localhost", "--browser.gatherUsageStats", "false", "--theme.base", "dark", "--theme.primaryColor", "#3b82f6", "--theme.backgroundColor", "#0f1419", "--theme.secondaryBackgroundColor", "#1e293b", ] subprocess.run(cmd, check=True) except subprocess.CalledProcessError as e: print(f"\nโŒ Failed to start DeepCode: {e}") print("Please check if Streamlit is properly installed.") sys.exit(1) except KeyboardInterrupt: print("\n\n๐Ÿ›‘ DeepCode server stopped by user") print("Thank you for using DeepCode! ๐Ÿงฌ") except Exception as e: print(f"\nโŒ Unexpected error: {e}") print("Please check your Python environment and try again.") sys.exit(1) finally: # Clean up cache files cleanup_cache() if __name__ == "__main__": main()