image prompt issues
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user