refac
This commit is contained in:
@@ -389,11 +389,16 @@ async def generate_image(
|
||||
images = await image_generations(
|
||||
request=__request__,
|
||||
form_data=CreateImageForm(prompt=prompt),
|
||||
metadata=(
|
||||
{'channel_id': __chat_id__.removeprefix('channel:'), 'message_id': __message_id__}
|
||||
if isinstance(__chat_id__, str) and __chat_id__.startswith('channel:')
|
||||
else None
|
||||
),
|
||||
user=user,
|
||||
)
|
||||
|
||||
# Prepare file entries for the images
|
||||
image_files = [{'type': 'image', 'url': img['url']} for img in images]
|
||||
image_files = [{'type': 'image', **img} for img in images]
|
||||
|
||||
# Persist files to DB if chat context is available
|
||||
if is_saved_chat_id(__chat_id__) and __message_id__ and images:
|
||||
@@ -457,11 +462,16 @@ async def edit_image(
|
||||
images = await image_edits(
|
||||
request=__request__,
|
||||
form_data=EditImageForm(prompt=prompt, image=image_urls),
|
||||
metadata=(
|
||||
{'channel_id': __chat_id__.removeprefix('channel:'), 'message_id': __message_id__}
|
||||
if isinstance(__chat_id__, str) and __chat_id__.startswith('channel:')
|
||||
else None
|
||||
),
|
||||
user=user,
|
||||
)
|
||||
|
||||
# Prepare file entries for the images
|
||||
image_files = [{'type': 'image', 'url': img['url']} for img in images]
|
||||
image_files = [{'type': 'image', **img} for img in images]
|
||||
|
||||
# Persist files to DB if chat context is available
|
||||
if is_saved_chat_id(__chat_id__) and __message_id__ and images:
|
||||
|
||||
Reference in New Issue
Block a user