Add helpful ImportError messages for optional dependencies

When optional dependencies are missing, raise ImportError with
installation
instructions pointing to the relevant extras group (e.g. `[messaging]`,
`[cli]`, `[mcp]`, etc.) instead of letting the import fail silently.
This commit is contained in:
alt-glitch 2026-04-23 04:46:01 +05:30
parent 79a5f03f92
commit 2df306e6cd
9 changed files with 81 additions and 14 deletions

View file

@ -318,7 +318,13 @@ def _resize_image_for_vision(image_path: Path, mime_type: Optional[str] = None,
else:
data_url = None # defer full encode; try Pillow resize first
from PIL import Image
try:
from PIL import Image
except ImportError:
raise ImportError(
"Pillow is required for image resizing. "
"Install with: pip install hermes-agent[cli]"
) from None
import io as _io
logger.info("Image file is %.1f MB (estimated base64 %.1f MB, limit %.1f MB), auto-resizing...",