RomZay commited on
Commit
86b031f
·
verified ·
1 Parent(s): 04c4599

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -24
app.py CHANGED
@@ -127,20 +127,9 @@ def render_message(history):
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
 
@@ -185,20 +174,11 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid
185
  last_message_state = gr.State("")
186
 
187
  def user_interaction(message, history, api_key, max_tokens, top_p, temperature):
188
-
189
  history, assistant_reply = respond(message, api_key, max_tokens, top_p, temperature)
190
 
191
  full_history_html = render_message(history)
192
 
193
- scroll_script = """
194
- <script>
195
- window.onload = function() {
196
- const container = document.getElementById('chatbox-container');
197
- container.scrollTop = container.scrollHeight; // Scroll to the bottom
198
- };
199
- </script>"""
200
-
201
- return full_history_html + scroll_script, history, "", message
202
 
203
 
204
 
 
127
  </div>
128
 
129
  <script>
130
+ // Ensure the chatbox scrolls to the bottom after each update
131
+ var chatboxContainer = document.getElementById('chatbox-container');
132
+ chatboxContainer.scrollTop = chatboxContainer.scrollHeight;
 
 
 
 
 
 
 
 
 
 
 
133
  </script>
134
  """
135
 
 
174
  last_message_state = gr.State("")
175
 
176
  def user_interaction(message, history, api_key, max_tokens, top_p, temperature):
 
177
  history, assistant_reply = respond(message, api_key, max_tokens, top_p, temperature)
178
 
179
  full_history_html = render_message(history)
180
 
181
+ return full_history_html, history, "", message
 
 
 
 
 
 
 
 
182
 
183
 
184