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