mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
refac
This commit is contained in:
parent
8cea0cf746
commit
bcd50ed8f1
1 changed files with 17 additions and 7 deletions
|
|
@ -716,17 +716,18 @@ async def chat_web_search_handler(
|
|||
return form_data
|
||||
|
||||
|
||||
def get_last_images(message_list):
|
||||
def get_images_from_messages(message_list):
|
||||
images = []
|
||||
|
||||
for message in reversed(message_list):
|
||||
images_flag = False
|
||||
|
||||
message_images = []
|
||||
for file in message.get("files", []):
|
||||
if file.get("type") == "image":
|
||||
images.append(file.get("url"))
|
||||
images_flag = True
|
||||
message_images.append(file.get("url"))
|
||||
|
||||
if images_flag:
|
||||
break
|
||||
if message_images:
|
||||
images.append(message_images)
|
||||
|
||||
return images
|
||||
|
||||
|
|
@ -780,7 +781,16 @@ async def chat_image_generation_handler(
|
|||
user_message = get_last_user_message(message_list)
|
||||
|
||||
prompt = user_message
|
||||
input_images = get_last_images(message_list)
|
||||
message_images = get_images_from_messages(message_list)
|
||||
|
||||
# Limit to first 2 sets of images
|
||||
# We may want to change this in the future to allow more images
|
||||
input_images = []
|
||||
for idx, images in enumerate(message_images):
|
||||
if idx >= 2:
|
||||
break
|
||||
for image in images:
|
||||
input_images.append(image)
|
||||
|
||||
system_message_content = ""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue