POLRAMBORA commited on
Commit
039fcd5
·
verified ·
1 Parent(s): 7ff88b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -126,7 +126,7 @@ def render_message(history):
126
  for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
127
  if user_message and user_message not in seen_messages:
128
  seen_messages.add(user_message)
129
- user_message_html = markdown.markdown(escape_html(user_message), extensions=["fenced_code", "codehilite"])
130
  messages_html += f"""
131
  <div style='display: flex; align-items: center; margin-bottom: 10px;'>
132
  <img src='{user_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>
@@ -135,7 +135,7 @@ def render_message(history):
135
 
136
  if assistant_message and assistant_message not in seen_messages:
137
  seen_messages.add(assistant_message)
138
- assistant_message_html = markdown.markdown(escape_html(assistant_message), extensions=["fenced_code", "codehilite"])
139
  messages_html += f"""
140
  <div style='display: flex; align-items: center; margin-bottom: 10px;'>
141
  <img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>
@@ -144,15 +144,11 @@ def render_message(history):
144
 
145
  messages_html += "</div></div>"
146
  return messages_html
147
-
 
148
  def escape_html(unsafe_text):
149
- return (
150
- unsafe_text.replace("&", "&amp;")
151
- .replace("<", "&lt;")
152
- .replace(">", "&gt;")
153
- .replace('"', "&quot;")
154
- .replace("'", "&#039;")
155
- )
156
 
157
  css="""
158
  .chatbox {height: 400px; overflow: auto; border: 1px solid #262626; padding: 10px; background-color: #171717; display: flex; flex-direction: column-reverse;}
 
126
  for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
127
  if user_message and user_message not in seen_messages:
128
  seen_messages.add(user_message)
129
+ user_message_html = escape_html(user_message)
130
  messages_html += f"""
131
  <div style='display: flex; align-items: center; margin-bottom: 10px;'>
132
  <img src='{user_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>
 
135
 
136
  if assistant_message and assistant_message not in seen_messages:
137
  seen_messages.add(assistant_message)
138
+ assistant_message_html = escape_html(assistant_message)
139
  messages_html += f"""
140
  <div style='display: flex; align-items: center; margin-bottom: 10px;'>
141
  <img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>
 
144
 
145
  messages_html += "</div></div>"
146
  return messages_html
147
+
148
+
149
  def escape_html(unsafe_text):
150
+ return ''.join(f"&#{ord(char)};" for char in unsafe_text)
151
+
 
 
 
 
 
152
 
153
  css="""
154
  .chatbox {height: 400px; overflow: auto; border: 1px solid #262626; padding: 10px; background-color: #171717; display: flex; flex-direction: column-reverse;}