fix
This commit is contained in:
@@ -149,14 +149,26 @@ class GenerationService:
|
||||
# 2. Получаем ассеты-референсы (если они есть)
|
||||
reference_assets: List[Asset] = []
|
||||
media_group_bytes: List[bytes] = []
|
||||
generation_prompt = "Create image for "
|
||||
generation_prompt = f"""
|
||||
You are an expert prompt engineer for Google Imagen 3.
|
||||
Create a single, detailed, natural language prompt for image generation based on these inputs:
|
||||
|
||||
$char_bio_inserted
|
||||
2. SCENE DESCRIPTION: {generation.prompt}
|
||||
|
||||
Rules:
|
||||
- Integrate the character's appearance naturally into the scene description.
|
||||
- Focus on lighting, texture, and composition (e.g. "cinematic lighting", "8k resolution").
|
||||
- Replace generic terms like "clean girl outfit" with specific visual descriptions (e.g. "minimalist beige cashmere sweater").
|
||||
- OUTPUT ONLY THE FINAL PROMPT TEXT. NO MARKDOWN.
|
||||
"""
|
||||
if generation.linked_character_id is not None:
|
||||
char_info = await self.dao.chars.get_character(generation.linked_character_id, with_image_data=True)
|
||||
if char_info is None:
|
||||
raise Exception(f"Character ID {generation.linked_character_id} not found")
|
||||
if generation.use_profile_image:
|
||||
media_group_bytes.append(char_info.character_image_data)
|
||||
generation_prompt = f"""Create image for character with bio: {char_info.character_bio}"""
|
||||
generation_prompt = generation_prompt.replace("$char_bio_inserted", f"1. CHARACTER BIO (Must be strictly followed): {char_info.character_bio}")
|
||||
|
||||
reference_assets = await self.dao.assets.get_assets_by_ids(generation.assets_list)
|
||||
# Извлекаем данные (bytes) из ассетов для отправки в Gemini
|
||||
@@ -166,7 +178,9 @@ class GenerationService:
|
||||
for asset in reference_assets
|
||||
if asset.data is not None and asset.type == AssetType.IMAGE
|
||||
)
|
||||
generation_prompt+=f" User also provide prompt: {generation.prompt}"
|
||||
if media_group_bytes:
|
||||
generation_prompt += " \n\n[Reference Image Guidance]: Use the provided image(s) as the STRICT reference for the main character's facial features and hair, enviroment or clothes. Maintain high fidelity to the reference identity."
|
||||
|
||||
logger.info(f"Final generation prompt assembled. Length: {len(generation_prompt)}. Media count: {len(media_group_bytes)}")
|
||||
|
||||
# 3. Запускаем процесс генерации и симуляцию прогресса
|
||||
@@ -183,7 +197,7 @@ class GenerationService:
|
||||
gemini=self.gemini
|
||||
)
|
||||
|
||||
# Update metrics from API (Common for both)
|
||||
|
||||
# Update metrics from API (Common for both)
|
||||
generation.api_execution_time_seconds = metrics.get("api_execution_time_seconds")
|
||||
generation.token_usage = metrics.get("token_usage")
|
||||
|
||||
Reference in New Issue
Block a user