Skip to content

Commit

Permalink
Don't render user message as if they are template strings
Browse files Browse the repository at this point in the history
  • Loading branch information
smathot committed Jan 20, 2024
1 parent 7b15bdf commit 3970d5a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion heymans/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""AI-based chatbot that provides sensible answers based on documentation"""

__version__ = '0.10.4'
__version__ = '0.10.5'
3 changes: 2 additions & 1 deletion heymans/routes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def chat_page():
html_class = 'message-ai'
else:
html_body = '<p>' + utils.clean(f'You: {message}',
escape_html=True) + '</p>'
escape_html=True,
render=False) + '</p>'
html_class = 'message-user'
if 'sources' in metadata:
sources_div = '<div class="message-sources">'
Expand Down
5 changes: 3 additions & 2 deletions heymans/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def md(text):
TocExtension()])


def clean(text, escape_html=True):
text = render_template_string(text)
def clean(text, escape_html=True, render=True):
if render:
text = render_template_string(text)
if escape_html:
text = html.escape(text).replace('\n', '<br>\n')
return text
Expand Down

0 comments on commit 3970d5a

Please sign in to comment.