Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -130,7 +130,7 @@ def render_message(history):
|
|
| 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;'>
|
| 133 |
-
<span style='color: white;'>{user_message_html}</span>
|
| 134 |
</div>"""
|
| 135 |
|
| 136 |
if assistant_message and assistant_message not in seen_messages:
|
|
@@ -139,7 +139,7 @@ def render_message(history):
|
|
| 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;'>
|
| 142 |
-
<span style='color: white;'>{assistant_message_html}</span>
|
| 143 |
</div>"""
|
| 144 |
|
| 145 |
messages_html += "</div></div>"
|
|
@@ -147,10 +147,11 @@ def render_message(history):
|
|
| 147 |
|
| 148 |
|
| 149 |
def escape_html(unsafe_text):
|
| 150 |
-
escaped_text = ''.join(f"&#{ord(char)};" if char
|
| 151 |
return escaped_text
|
| 152 |
|
| 153 |
|
|
|
|
| 154 |
css="""
|
| 155 |
.chatbox {height: 400px; overflow: auto; border: 1px solid #262626; padding: 10px; background-color: #171717; display: flex; flex-direction: column-reverse;}
|
| 156 |
"""
|
|
|
|
| 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;'>
|
| 133 |
+
<span style='color: white; white-space: pre-wrap;'>{user_message_html}</span>
|
| 134 |
</div>"""
|
| 135 |
|
| 136 |
if assistant_message and assistant_message not in seen_messages:
|
|
|
|
| 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;'>
|
| 142 |
+
<span style='color: white; white-space: pre-wrap;'>{assistant_message_html}</span>
|
| 143 |
</div>"""
|
| 144 |
|
| 145 |
messages_html += "</div></div>"
|
|
|
|
| 147 |
|
| 148 |
|
| 149 |
def escape_html(unsafe_text):
|
| 150 |
+
escaped_text = ''.join(f"&#{ord(char)};" if char not in ('\n', '\r') else '<br>' for char in unsafe_text)
|
| 151 |
return escaped_text
|
| 152 |
|
| 153 |
|
| 154 |
+
|
| 155 |
css="""
|
| 156 |
.chatbox {height: 400px; overflow: auto; border: 1px solid #262626; padding: 10px; background-color: #171717; display: flex; flex-direction: column-reverse;}
|
| 157 |
"""
|