RomZay commited on
Commit
b20833c
·
verified ·
1 Parent(s): 8000fad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -20
app.py CHANGED
@@ -129,30 +129,25 @@ def render_message(history):
129
 
130
  js = """
131
  function Scrolldown() {
132
- function startObserver() {
133
- let targetNode = document.querySelector('#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
- startObserver();
 
 
 
 
 
 
 
152
  }
153
 
154
- // Ensure function is available globally
155
- window.Scrolldown = Scrolldown;
156
  """
157
  with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}", js=js) as demo:
158
 
 
129
 
130
  js = """
131
  function Scrolldown() {
132
+ let targetNode = document.querySelector('#chatbox-container');
133
+
134
+ if (!targetNode) {
135
+ console.log("Chatbox container not found, retrying in 1 second...");
136
+ setTimeout(Scrolldown, 1000);
137
+ return;
 
 
 
 
 
 
 
 
 
 
 
138
  }
139
 
140
+ console.log("Chatbox container found, starting observer");
141
+
142
+ const config = { childList: true, subtree: true };
143
+ const callback = (mutationList, observer) => {
144
+ targetNode.scrollTop = targetNode.scrollHeight;
145
+ };
146
+ const observer = new MutationObserver(callback);
147
+ observer.observe(targetNode, config);
148
  }
149
 
150
+ Scrolldown();
 
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:
153