Skip to content

Commit 33a4d1b

Browse files
fix: image url to base64 conversion (open-webui#23685)
1 parent c8ef7b0 commit 33a4d1b

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

backend/open_webui/utils/middleware.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,13 +2054,16 @@ async def convert_url_images_to_base64(form_data):
20542054
continue
20552055

20562056
try:
2057-
base64_data = await asyncio.to_thread(get_image_base64_from_url, image_url)
2058-
new_content.append(
2059-
{
2060-
'type': 'image_url',
2061-
'image_url': {'url': base64_data},
2062-
}
2063-
)
2057+
base64_data = await get_image_base64_from_url(image_url)
2058+
if base64_data:
2059+
new_content.append(
2060+
{
2061+
'type': 'image_url',
2062+
'image_url': {'url': base64_data},
2063+
}
2064+
)
2065+
else:
2066+
new_content.append(item)
20642067
except Exception as e:
20652068
log.debug(f'Error converting image URL to base64: {e}')
20662069
new_content.append(item)

0 commit comments

Comments
 (0)