ghmk Claude commited on
Commit
6c4db38
·
1 Parent(s): 4fac583

Fix: Skip non-Image items when saving character sheet stages

Browse files

The stages dictionary contains both images and metadata (prompts, etc).
When saving stages to disk, the code was trying to save prompt strings
as images, which caused ensure_pil_image() to treat them as file paths
and throw "Image path not found: {prompt text}" exceptions.

This fix adds isinstance(item, Image.Image) check to only save actual
PIL Images, skipping prompt strings and other metadata.

Now character sheets display successfully even when safety filters
trigger retries or individual stages fail with placeholders.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

character_forge_image/services/character_forge_service.py CHANGED
@@ -1132,11 +1132,11 @@ class CharacterForgeService:
1132
  metadata=metadata
1133
  )
1134
 
1135
- # Save individual stages
1136
- for stage_name, image in stages.items():
1137
- if stage_name != 'character_sheet':
1138
  save_image(
1139
- image=image,
1140
  directory=char_dir / "stages",
1141
  base_name=f"{safe_name}_{stage_name}",
1142
  metadata=None
 
1132
  metadata=metadata
1133
  )
1134
 
1135
+ # Save individual stages (skip prompts and other metadata)
1136
+ for stage_name, item in stages.items():
1137
+ if stage_name != 'character_sheet' and isinstance(item, Image.Image):
1138
  save_image(
1139
+ image=item,
1140
  directory=char_dir / "stages",
1141
  base_name=f"{safe_name}_{stage_name}",
1142
  metadata=None