Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -122,10 +122,29 @@ def render_message(history):
|
|
| 122 |
messages_html += f"<img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
|
| 123 |
messages_html += f"<span style='color: white;'>{assistant_message}</span></div><br>"
|
| 124 |
|
| 125 |
-
messages_html += "
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
|
|
|
| 129 |
|
| 130 |
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}") as demo:
|
| 131 |
|
|
|
|
| 122 |
messages_html += f"<img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
|
| 123 |
messages_html += f"<span style='color: white;'>{assistant_message}</span></div><br>"
|
| 124 |
|
| 125 |
+
messages_html += """
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
+
|
| 129 |
+
<script>
|
| 130 |
+
let chatboxContainer = document.getElementById('chatbox-container');
|
| 131 |
+
let isScrolledToBottom = chatboxContainer.scrollTop + chatboxContainer.clientHeight === chatboxContainer.scrollHeight;
|
| 132 |
+
|
| 133 |
+
window.onload = function() {
|
| 134 |
+
if (isScrolledToBottom) {
|
| 135 |
+
chatboxContainer.scrollTop = chatboxContainer.scrollHeight;
|
| 136 |
+
}
|
| 137 |
+
};
|
| 138 |
+
|
| 139 |
+
window.onchange = function() {
|
| 140 |
+
if (isScrolledToBottom) {
|
| 141 |
+
chatboxContainer.scrollTop = chatboxContainer.scrollHeight;
|
| 142 |
+
}
|
| 143 |
+
};
|
| 144 |
+
</script>
|
| 145 |
+
"""
|
| 146 |
|
| 147 |
+
return messages_html
|
| 148 |
|
| 149 |
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}") as demo:
|
| 150 |
|