Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -122,18 +122,25 @@ 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 |
-
</div>
|
| 127 |
-
</div>
|
| 128 |
|
|
|
|
| 129 |
<script>
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
</script>
|
| 134 |
"""
|
| 135 |
|
| 136 |
-
return messages_html
|
| 137 |
|
| 138 |
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}") as demo:
|
| 139 |
|
|
|
|
| 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 += "</div></div>"
|
|
|
|
|
|
|
| 126 |
|
| 127 |
+
scroll_script = """
|
| 128 |
<script>
|
| 129 |
+
const container = document.getElementById('chatbox-container');
|
| 130 |
+
|
| 131 |
+
const observer = new MutationObserver(() => {
|
| 132 |
+
container.scrollTop = container.scrollHeight; // Force scroll to bottom after re-render
|
| 133 |
+
});
|
| 134 |
+
|
| 135 |
+
observer.observe(container, { childList: true, subtree: true });
|
| 136 |
+
|
| 137 |
+
window.onload = function() {
|
| 138 |
+
container.scrollTop = container.scrollHeight;
|
| 139 |
+
};
|
| 140 |
</script>
|
| 141 |
"""
|
| 142 |
|
| 143 |
+
return messages_html + scroll_script
|
| 144 |
|
| 145 |
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}") as demo:
|
| 146 |
|