Scott Cogan commited on
Commit
2304ec1
·
1 Parent(s): 79161d9

fix: simplify template processing and remove unnecessary escaping

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -206,11 +206,10 @@ with open("prompts.yaml", 'r') as stream:
206
  content = re.sub(r'{{([^{}]+)}}', r'{{ \1 }}', content)
207
  content = re.sub(r'{%([^{}]+)%}', r'{% \1 %}', content)
208
  else:
209
- # For other templates, wrap non-template content
210
  content = subvalue
211
  if '{{' not in content and '{%' not in content:
212
- escaped_content = content.replace('"', '\\"')
213
- content = f'{{{{ "{escaped_content}" }}}}'
214
  else:
215
  # Ensure proper spacing in template expressions
216
  content = re.sub(r'{{([^{}]+)}}', r'{{ \1 }}', content)
@@ -224,11 +223,10 @@ with open("prompts.yaml", 'r') as stream:
224
  content = re.sub(r'{{([^{}]+)}}', r'{{ \1 }}', content)
225
  content = re.sub(r'{%([^{}]+)%}', r'{% \1 %}', content)
226
  else:
227
- # For other templates, wrap non-template content
228
  content = value
229
  if '{{' not in content and '{%' not in content:
230
- escaped_content = content.replace('"', '\\"')
231
- content = f'{{{{ "{escaped_content}" }}}}'
232
  else:
233
  # Ensure proper spacing in template expressions
234
  content = re.sub(r'{{([^{}]+)}}', r'{{ \1 }}', content)
 
206
  content = re.sub(r'{{([^{}]+)}}', r'{{ \1 }}', content)
207
  content = re.sub(r'{%([^{}]+)%}', r'{% \1 %}', content)
208
  else:
209
+ # For other templates, only wrap if not already a template
210
  content = subvalue
211
  if '{{' not in content and '{%' not in content:
212
+ content = f'{{{{ "{content}" }}}}'
 
213
  else:
214
  # Ensure proper spacing in template expressions
215
  content = re.sub(r'{{([^{}]+)}}', r'{{ \1 }}', content)
 
223
  content = re.sub(r'{{([^{}]+)}}', r'{{ \1 }}', content)
224
  content = re.sub(r'{%([^{}]+)%}', r'{% \1 %}', content)
225
  else:
226
+ # For other templates, only wrap if not already a template
227
  content = value
228
  if '{{' not in content and '{%' not in content:
229
+ content = f'{{{{ "{content}" }}}}'
 
230
  else:
231
  # Ensure proper spacing in template expressions
232
  content = re.sub(r'{{([^{}]+)}}', r'{{ \1 }}', content)