image prompt issues

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-25 01:17:41 +00:00
parent 64e76f5436
commit abeede5f04
7 changed files with 150 additions and 45 deletions

View File

@@ -130,20 +130,24 @@ class PromptRegistry:
logger.debug(f"Replaced placeholder {placeholder} with {len(str(value))} characters")
# Step 2: Try .format() style for {variable} placeholders (if any remain)
# Normalize context keys - convert UPPER to lowercase for .format()
# Normalize context keys - provide both original case, lowercase, and uppercase
normalized_context = {}
for key, value in context.items():
# Try both original key and lowercase version
# Add original key
normalized_context[key] = value
# Add lowercase version
normalized_context[key.lower()] = value
# Add uppercase version
normalized_context[key.upper()] = value
# Only try .format() if there are {variable} placeholders
if '{' in rendered and '}' in rendered:
try:
rendered = rendered.format(**normalized_context)
logger.debug(f"Successfully formatted prompt with context keys: {list(context.keys())}")
except (KeyError, ValueError, IndexError) as e:
# If .format() fails, log warning but keep the [IGNY8_*] replacements
logger.warning(f"Failed to format prompt with .format(): {e}. Using [IGNY8_*] replacements only.")
logger.warning(f"Failed to format prompt with .format(): {e}. Context keys: {list(context.keys())}. Using [IGNY8_*] replacements only.")
return rendered