From 2b612dea36da8d6c9aa90ce875c693448e51ca48 Mon Sep 17 00:00:00 2001 From: Hiroshi Nishio Date: Tue, 7 Jan 2025 12:40:59 +0900 Subject: [PATCH] Fix an error in describe_image: You uploaded an unsupported image. Please make sure your image has of one the following formats: ['png', 'jpeg', 'gif', 'webp']. --- utils/extract_urls.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/extract_urls.py b/utils/extract_urls.py index 8584e05f..9cc010be 100644 --- a/utils/extract_urls.py +++ b/utils/extract_urls.py @@ -4,13 +4,17 @@ @handle_exceptions(default_return_value=[], raise_on_error=False) def extract_image_urls(text: str) -> list[dict[str, str]]: - """Extract alt text and URLs from img tags in the given text. + """Extract alt text and URLs from img tags in the given text. Excludes SVG images. Example: Screenshot 2024-12-12 at 6 25 41 PM """ pattern = r']*alt="([^"]*)"[^>]*src="([^"]*)"[^>]*>' matches = findall(pattern, text) - return [{"alt": alt, "url": url} for alt, url in matches] + return [ + {"alt": alt, "url": url} + for alt, url in matches + if not url.lower().endswith(".svg") + ] def extract_urls(text: str) -> tuple[list[str], list[str]]: