fixed text chunking

This commit is contained in:
Karl 2025-09-23 15:37:07 +01:00
parent 61ddf2f2aa
commit 36ff97e44a

View File

@ -250,14 +250,10 @@ def generate_prompts_for_players(players, app_config):
# Chunk the prompt if it's too long for CLIP
prompt_chunks = chunk_prompt_for_clip(prompt)
# Create a prompt entry for each chunk
for i, chunk in enumerate(prompt_chunks):
if len(prompt_chunks) > 1:
# If we have multiple chunks, add a chunk identifier
chunked_prompt = f"{player[0]}_chunk_{i+1}:{chunk}"
else:
chunked_prompt = f"{player[0]}:{chunk}"
prompts.append(chunked_prompt)
# Use the first chunk (most important part) for image generation
# This ensures each player generates exactly one image
final_prompt = prompt_chunks[0] if prompt_chunks else prompt
prompts.append(f"{player[0]}:{final_prompt}")
except KeyError as e:
logging.warning(f"Key error while generating prompt for player: {e}")