From ecb512995c56468e8ce6b10dc6aac7af02e0e721 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Thu, 27 Nov 2025 10:28:04 +0800 Subject: [PATCH] feat(civitai): expand image metadata detection criteria, see #700 Add additional CivitAI image metadata fields to detection logic including generation parameters (prompt, steps, sampler, etc.) and model information. Also improve LoRA hash detection by checking both main metadata and nested meta objects. This ensures more comprehensive identification of CivitAI image metadata across different response formats. --- py/recipes/parsers/civitai_image.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/py/recipes/parsers/civitai_image.py b/py/recipes/parsers/civitai_image.py index 41e1e9f2..f3b4f8ba 100644 --- a/py/recipes/parsers/civitai_image.py +++ b/py/recipes/parsers/civitai_image.py @@ -25,27 +25,41 @@ class CivitaiApiMetadataParser(RecipeMetadataParser): return False def has_markers(payload: Dict[str, Any]) -> bool: - return any( - key in payload - for key in ( - "resources", - "civitaiResources", - "additionalResources", - ) + # Check for common CivitAI image metadata fields + civitai_image_fields = ( + "resources", + "civitaiResources", + "additionalResources", + "hashes", + "prompt", + "negativePrompt", + "steps", + "sampler", + "cfgScale", + "seed", + "width", + "height", + "Model", + "Model hash" ) + return any(key in payload for key in civitai_image_fields) + # Check the main metadata object if has_markers(metadata): return True + # Check for LoRA hash patterns hashes = metadata.get("hashes") if isinstance(hashes, dict) and any(str(key).lower().startswith("lora:") for key in hashes): return True + # Check nested meta object (common in CivitAI image responses) nested_meta = metadata.get("meta") if isinstance(nested_meta, dict): if has_markers(nested_meta): return True + # Also check for LoRA hash patterns in nested meta hashes = nested_meta.get("hashes") if isinstance(hashes, dict) and any(str(key).lower().startswith("lora:") for key in hashes): return True