Spaces:
Runtime error
Runtime error
Scott Cogan commited on
Commit ·
2b4635e
1
Parent(s): 1c47798
fix: Preserve system prompt template variables
Browse files
app.py
CHANGED
|
@@ -92,10 +92,12 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 92 |
# Log the exact content before processing
|
| 93 |
logger.debug(f"Raw template content: {value}")
|
| 94 |
|
| 95 |
-
# For system prompt,
|
| 96 |
if is_system_prompt:
|
| 97 |
-
|
| 98 |
-
value =
|
|
|
|
|
|
|
| 99 |
else:
|
| 100 |
# For other templates, wrap non-template content
|
| 101 |
if '{{' not in value and '{%' not in value:
|
|
|
|
| 92 |
# Log the exact content before processing
|
| 93 |
logger.debug(f"Raw template content: {value}")
|
| 94 |
|
| 95 |
+
# For system prompt, ensure proper spacing in template expressions
|
| 96 |
if is_system_prompt:
|
| 97 |
+
# Ensure proper spacing in template expressions
|
| 98 |
+
value = re.sub(r'{{([^{}]+)}}', lambda m: '{{ ' + m.group(1).strip() + ' }}', value)
|
| 99 |
+
value = re.sub(r'{%([^{}]+)%}', lambda m: '{% ' + m.group(1).strip() + ' %}', value)
|
| 100 |
+
value = value.replace('\n', '\\n')
|
| 101 |
else:
|
| 102 |
# For other templates, wrap non-template content
|
| 103 |
if '{{' not in value and '{%' not in value:
|