Skip to content

Build and run agents you can see, understand and trust.

fix(rag): accept a 12-byte webp header in the media type sniffer (#2934)

ANIRUDDHA ADAKd8ebf89b6ce3
diff --git a/src/agentscope/rag/_parser/_utils.py b/src/agentscope/rag/_parser/_utils.py
index 5172d8a61..7a62e3968 100644
--- a/src/agentscope/rag/_parser/_utils.py
+++ b/src/agentscope/rag/_parser/_utils.py
@@ -42,7 +42,7 @@ def _guess_image_media_type(data: bytes) -> str:
if data.startswith(signature):
return media_type
# WebP: ``RIFF`` at offset 0 + ``WEBP`` at offset 8.
- if len(data) > 12 and data[:4] == b"RIFF" and data[8:12] == b"WEBP":
+ if len(data) >= 12 and data[:4] == b"RIFF" and data[8:12] == b"WEBP":
return "image/webp"
return "image/jpeg"