Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 =
|
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 =
|
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 |
-
|
151 |
-
.replace("<", "<")
|
152 |
-
.replace(">", ">")
|
153 |
-
.replace('"', """)
|
154 |
-
.replace("'", "'")
|
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;}
|