+ fixes
This commit is contained in:
@@ -329,7 +329,16 @@ async def generate_image(
|
||||
bot: Bot,
|
||||
gemini: GoogleAdapter
|
||||
) -> List[BufferedInputFile]:
|
||||
state_value = await state.get_state()
|
||||
media_group_bytes = []
|
||||
ar = AspectRatios.NINESIXTEEN
|
||||
quality = Quality.TWOK
|
||||
|
||||
if state_value is None:
|
||||
|
||||
data = await state.get_data()
|
||||
ar = AspectRatios[data['aspect_ratio']]
|
||||
quality = Quality[data['quality']]
|
||||
char_id = data.get("char_id")
|
||||
if not char_id:
|
||||
raise ValueError("Character ID not found in state")
|
||||
@@ -338,8 +347,9 @@ async def generate_image(
|
||||
|
||||
# Начинаем список с фото персонажа
|
||||
file_byes = await bot.download(char.character_image_doc_tg_id)
|
||||
media_group_bytes = [file_byes.read()]
|
||||
media_group_bytes.append(file_byes.read())
|
||||
file_byes.close()
|
||||
|
||||
if media:
|
||||
# Скачиваем файлы
|
||||
# tasks вернут список объектов BytesIO
|
||||
@@ -362,8 +372,8 @@ async def generate_image(
|
||||
gemini.generate_image,
|
||||
prompt=prompt,
|
||||
images_list=media_group_bytes,
|
||||
aspect_ratio=AspectRatios[data['aspect_ratio']],
|
||||
quality=Quality[data['quality']],
|
||||
aspect_ratio=ar,
|
||||
quality=quality,
|
||||
)
|
||||
|
||||
images = []
|
||||
@@ -378,7 +388,7 @@ async def generate_image(
|
||||
images.append(
|
||||
BufferedInputFile(
|
||||
content,
|
||||
filename=f"img_{random.randint(1000, 9999)}.png"
|
||||
filename=f"img_{random.randint(1000, 99999)}.png"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user