|
|
|
|
|
""" |
|
|
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 = [] |
|
|
|
|
|
|
|
|
if importlib.util.find_spec("streamlit") is not None: |
|
|
print("β
Streamlit is installed") |
|
|
else: |
|
|
missing_deps.append("streamlit>=1.28.0") |
|
|
|
|
|
|
|
|
if importlib.util.find_spec("yaml") is not None: |
|
|
print("β
PyYAML is installed") |
|
|
else: |
|
|
missing_deps.append("pyyaml") |
|
|
|
|
|
|
|
|
if importlib.util.find_spec("asyncio") is not None: |
|
|
print("β
Asyncio is available") |
|
|
else: |
|
|
missing_deps.append("asyncio") |
|
|
|
|
|
|
|
|
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)") |
|
|
|
|
|
|
|
|
try: |
|
|
import subprocess |
|
|
import platform |
|
|
|
|
|
subprocess_kwargs = { |
|
|
"capture_output": True, |
|
|
"text": True, |
|
|
"timeout": 5, |
|
|
} |
|
|
|
|
|
if platform.system() == "Windows": |
|
|
subprocess_kwargs["creationflags"] = 0x08000000 |
|
|
|
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
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...") |
|
|
|
|
|
os.system('find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null') |
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
if not check_dependencies(): |
|
|
print("\nπ¨ Please install missing dependencies and try again.") |
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
current_dir = Path(__file__).parent |
|
|
streamlit_app_path = current_dir / "ui" / "streamlit_app.py" |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
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: |
|
|
|
|
|
cleanup_cache() |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
main() |
|
|
|