Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -129,24 +129,26 @@ def render_message(history):
|
|
129 |
|
130 |
js = """
|
131 |
function Scrolldown() {
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
|
141 |
-
|
142 |
-
|
143 |
-
const callback = (mutationList, observer) => {
|
144 |
-
targetNode.scrollTop = targetNode.scrollHeight;
|
145 |
-
};
|
146 |
-
|
147 |
-
const observer = new MutationObserver(callback);
|
148 |
-
|
149 |
-
observer.observe(targetNode, config);
|
150 |
}
|
151 |
"""
|
152 |
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}", js=js) as demo:
|
|
|
129 |
|
130 |
js = """
|
131 |
function Scrolldown() {
|
132 |
+
function startObserver() {
|
133 |
+
let targetNode = document.getElementById('chatbox-container');
|
134 |
+
|
135 |
+
if (!targetNode) {
|
136 |
+
console.log("Chatbox container not found, retrying in 1 second...");
|
137 |
+
setTimeout(startObserver, 1000);
|
138 |
+
return;
|
139 |
+
}
|
140 |
+
|
141 |
+
console.log("Chatbox container found, starting observer");
|
142 |
+
|
143 |
+
const config = { childList: true, subtree: true };
|
144 |
+
const callback = (mutationList, observer) => {
|
145 |
+
targetNode.scrollTop = targetNode.scrollHeight;
|
146 |
+
};
|
147 |
+
const observer = new MutationObserver(callback);
|
148 |
+
observer.observe(targetNode, config);
|
149 |
}
|
150 |
|
151 |
+
document.addEventListener("DOMContentLoaded", startObserver);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
"""
|
154 |
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}", js=js) as demo:
|