community: fix import exception too constrictive (#30218)

Fix this issue #30097
This commit is contained in:
amuwall 2025-03-18 10:09:02 +08:00 committed by GitHub
parent 7ff7c4f81b
commit f6a17fbc56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,6 +45,11 @@ class BaseImageBlobParser(BaseBlobParser):
"""
try:
from PIL import Image as Img
except ImportError:
raise ImportError(
"`Pillow` package not found, please install it with "
"`pip install Pillow`"
)
with blob.as_bytes_io() as buf:
if blob.mimetype == "application/x-npy":
@ -57,11 +62,6 @@ class BaseImageBlobParser(BaseBlobParser):
page_content=content,
metadata={**blob.metadata, **{"source": blob.source}},
)
except ImportError:
raise ImportError(
"`Pillow` package not found, please install it with "
"`pip install Pillow`"
)
class RapidOCRBlobParser(BaseImageBlobParser):