mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-04 19:29:27 -05:00
refac
This commit is contained in:
21
backend/open_webui/utils/files.py
Normal file
21
backend/open_webui/utils/files.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from open_webui.routers.images import (
|
||||
load_b64_image_data,
|
||||
upload_image,
|
||||
)
|
||||
|
||||
|
||||
def get_image_url_from_base64(request, base64_image_string, metadata, user):
|
||||
if "data:image/png;base64" in base64_image_string:
|
||||
image_url = ""
|
||||
# Extract base64 image data from the line
|
||||
image_data, content_type = load_b64_image_data(base64_image_string)
|
||||
if image_data is not None:
|
||||
image_url = upload_image(
|
||||
request,
|
||||
image_data,
|
||||
content_type,
|
||||
metadata,
|
||||
user,
|
||||
)
|
||||
return image_url
|
||||
return None
|
||||
Reference in New Issue
Block a user