# backend/requirements-base.txt
# Base requirements WITHOUT PyTorch (installed separately based on GPU)
# IMPORTANT: Keep in sync with requirements.txt — start.sh prefers this file

# Core Flask/Backend Dependencies
Flask==3.1.3
Flask-Executor==1.0.0
Flask-Migrate==4.1.0
Flask-SQLAlchemy==3.1.1
Flask-SocketIO==5.7.0
flask-cors==6.0.5
alembic==1.20.0
anthropic>=1.7.0
python-dotenv==1.2.4

# Background Tasks & Caching
celery==5.7.0
# kombu 5.7 refuses redis-py below 6.4 at run time, so the two move together.
# redis-py 8 speaks RESP3 and needs a Redis server of 6.0 or newer.
kombu==5.7.0
redis==8.1.0
eventlet==0.41.2
# Cron expressions for scheduled tasks (backend/api/task_scheduler_api.py).
croniter==6.2.4

# Data Processing & Analysis
numpy<2.0,>=1.26.4  # Pin to <2.0 for PyTorch compatibility
pandas==2.2.2
pydantic==2.14.1
psutil==7.2.2
# regex runs search_code's caller-supplied patterns under a per-call timeout
# (backend/tools/llama_code_tools.py). transformers, nltk and tiktoken install it
# too; it is named here because backend code imports it directly. The floor is
# the one transformers 5.16 already requires.
regex>=2025.10.22

# Web Scraping & File Processing
beautifulsoup4==4.15.0
lxml==6.1.3
pypdf==6.21.4
requests==2.34.2
# Transitive dependencies (Flask, requests, llama-index-core) named only to hold a
# security floor: unnamed, an existing venv keeps whatever release it already has.
Werkzeug>=3.1.9
urllib3>=2.8.0
aiohttp>=3.14.5
# Interconnector machine keys and request signatures (backend/utils/node_auth.py,
# Ed25519); kept in step with requirements.txt.
cryptography>=50.0.2
# HTTP client for web search (backend/utils/bing_search.py): requests with a
# browser's TLS and header profile.
primp==2.0.1

# Database & Utilities
psycopg2-binary==2.9.9
python-slugify==8.0.4
loguru==0.7.2

# LLM/AI Dependencies (without torch)
llama-index-core>=0.14.26,<0.15.0
llama-index-llms-ollama>=0.12.0
llama-index-embeddings-ollama>=0.11.0
llama-index-readers-file>=0.5.0  # Updated for llama-index-core 0.14.x
# Retrieval storage and reranking. Both were silent missing deps: without the
# pgvector store the index falls back to SimpleVectorStore and reports success
# throughout — measured 0/7 needles retrieved on scripts/rag_validation, 6/7 at
# rank 1 once installed. Without sentence-transformers the cross-encoder rerank
# is skipped. Verified at 0.8.1 / 6.0.0 against llama-index-core 0.14.24.
llama-index-vector-stores-postgres>=0.10.0
sentence-transformers>=6.0.1
# Layout-aware parsing for .pdf/.docx/.pptx (backend/utils/docling_loader.py).
# Without it those formats have no reader at all and fall through to a legacy
# path that raises. Pulls rapidocr, which requires opencv-python>=4.5 with no
# upper bound, so install under backend/constraints.txt (PIP_CONSTRAINT) to keep
# numpy<2.0. Verified at 2.150.1: numpy 1.26.4 and opencv-python 4.11.0.86 held.
docling>=2.142.0  # first release whose parser and layout models accept Pillow 13

# Image Generation Dependencies (without torch)
diffusers>=0.43.0
transformers>=5.2.0,<6.0  # Krea2/Qwen3-VL needs 5.2+ (rope_parameters); was <5.0 for legacy ComfyUI pin
# A range, not a pin: Settings > Training libraries moves accelerate to 1.4+ (TRL
# needs it, and transformers' Trainer calls unwrap_model(keep_torch_compile=),
# new in 1.3), and an exact pin here would put it back on the next start-up's
# `pip install -r`. Verified at 1.15.0: diffusers 0.40 model and sequential CPU
# offload, transformers 5.16 Trainer and device_map, peft 0.20.
accelerate>=1.15.0,<2
peft>=0.20.0  # Z-Image LoRA training runs in this venv (plugins/lora_trainer/scripts/run_zimage_trainer.py); without it training stops at "train deps missing: No module named 'peft'"
safetensors>=0.8.0
Pillow>=13.0.0  # aligned with requirements.txt. 13.0.0 is the fixed release: every
                # 12.x carries published advisories (heap OOB writes, decompression-bomb
                # bypasses). NOTE: the PyTorch wheel index tops out at Pillow 12.2.0,
                # so install_pytorch.sh re-pins this AFTER torch.

# ComfyUI / Video Generation Dependencies
torchsde>=0.2.6
sentencepiece>=0.2.2
kornia>=0.7.1
spandrel>=0.4.2
av>=18.1.0
pydantic-settings>=2.15.0

# Face-restore heavy CV deps moved to the OPTIONAL extra
# backend/requirements-cv.txt (P3-10b): gfpgan, realesrgan, facexlib, basicsr,
# lmdb, tb-nightly, opencv-python. They lack aarch64/Pi wheels and aborted the
# whole install; only the (lazy, guarded) face_restoration_service uses them.
# scipy/tqdm/PyYAML stay here — shared transitive deps of the always-on stack.
scipy>=1.10.0  # used by image/audio paths; also a GFPGAN dep
tqdm>=4.65.0   # transitive dep of transformers/huggingface_hub (always-on)
PyYAML>=6.0    # transitive dep of transformers/huggingface_hub (always-on)

# Video Processing Dependencies
imageio==2.38.1
imageio-ffmpeg==0.6.0

# Voice Processing Dependencies
piper-tts==1.8.0
onnxruntime==1.30.0

# Testing Dependencies
pytest==9.0.3
pytest-timeout==2.4.0
pytest-playwright==0.8.0  # 0.7.0 caps pytest<9.0.0; 0.8.0 supports pytest 9.x
playwright==1.52.0

# Desktop Automation Dependencies
pyautogui>=0.9.54      # GUI automation (mouse, keyboard)
pynput>=1.8.2          # Keyboard/mouse monitoring
watchdog>=6.0.0        # File system monitoring
pyperclip>=1.8.2       # Cross-platform clipboard
plyer>=2.1.0           # Native notifications
pathspec>=1.1.1       # gitignore_filter / upload_api — required for upload blueprint
