fix(telegram): route image documents (.png/.jpg/.webp/.gif) through vision pipeline
When users send images as documents (Telegram file picker), they were rejected with "Unsupported document type" because SUPPORTED_DOCUMENT_TYPES only includes text/office formats. Add SUPPORTED_IMAGE_DOCUMENT_TYPES to base.py and handle them in telegram.py before the document check. - Add SUPPORTED_IMAGE_DOCUMENT_TYPES constant to base.py - Add MIME reverse-lookup for image types in telegram.py - Route image documents through cache_image_from_bytes + vision pipeline - Handle media groups for image documents Closes: #20128, #18620
This commit is contained in:
@@ -837,6 +837,26 @@ SUPPORTED_DOCUMENT_TYPES = {
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Image document types
|
||||
#
|
||||
# Image extensions that platforms may deliver as "documents" rather than
|
||||
# native photo attachments (Telegram users uploading via the file picker,
|
||||
# clients that wrap stickers/screenshots as files, etc.). When we see one
|
||||
# of these, we route the bytes through the image cache and the normal
|
||||
# vision/photo handling path instead of rejecting them as unsupported
|
||||
# documents.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
SUPPORTED_IMAGE_DOCUMENT_TYPES = {
|
||||
".jpg": "image/jpeg",
|
||||
".jpeg": "image/jpeg",
|
||||
".png": "image/png",
|
||||
".webp": "image/webp",
|
||||
".gif": "image/gif",
|
||||
}
|
||||
|
||||
|
||||
def get_document_cache_dir() -> Path:
|
||||
"""Return the document cache directory, creating it if it doesn't exist."""
|
||||
DOCUMENT_CACHE_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user