This commit is contained in:
Timothy Jaeryang Baek
2025-12-22 00:39:05 +04:00
parent 01e88c6ac2
commit 446cc0ac60
3 changed files with 75 additions and 17 deletions
+4 -1
View File
@@ -14,6 +14,8 @@ from typing import Optional
from pathlib import Path
from open_webui.storage.provider import Storage
from open_webui.models.chats import Chats
from open_webui.models.files import Files
from open_webui.routers.files import upload_file_handler
@@ -65,13 +67,14 @@ def get_image_url_from_base64(request, base64_image_string, metadata, user):
# Extract base64 image data from the line
image_data, content_type = get_image_data(base64_image_string)
if image_data is not None:
image_url = upload_image(
_, image_url = upload_image(
request,
image_data,
content_type,
metadata,
user,
)
return image_url
return None
+20 -2
View File
@@ -799,6 +799,10 @@ async def chat_image_generation_handler(
images = await image_edits(
request=request,
form_data=EditImageForm(**{"prompt": prompt, "image": input_images}),
metadata={
"chat_id": metadata.get("chat_id", None),
"message_id": metadata.get("message_id", None),
},
user=user,
)
@@ -824,7 +828,7 @@ async def chat_image_generation_handler(
}
)
system_message_content = "<context>The requested image has been created and is now being shown to the user. Let them know that it has been generated.</context>"
system_message_content = "<context>The requested image has been edited and created and is now being shown to the user. Let them know that it has been generated.</context>"
except Exception as e:
log.debug(e)
@@ -883,6 +887,10 @@ async def chat_image_generation_handler(
images = await image_generations(
request=request,
form_data=CreateImageForm(**{"prompt": prompt}),
metadata={
"chat_id": metadata.get("chat_id", None),
"message_id": metadata.get("message_id", None),
},
user=user,
)
@@ -2737,7 +2745,17 @@ async def process_chat_response(
if ENABLE_CHAT_RESPONSE_BASE64_IMAGE_URL_CONVERSION:
value = convert_markdown_base64_images(
request, value, metadata, user
request,
value,
{
"chat_id": metadata.get(
"chat_id", None
),
"message_id": metadata.get(
"message_id", None
),
},
user,
)
content = f"{content}{value}"