RomZay commited on
Commit
ac8a166
·
verified ·
1 Parent(s): 2ce7301

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -105,6 +105,7 @@ def render_message(history):
105
  messages_html = """
106
  <div id="chatbox-container" class="chatbox">
107
  <div id="messages">"""
 
108
  for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
109
  if user_message:
110
  messages_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
@@ -123,25 +124,18 @@ def render_message(history):
123
  </div>
124
 
125
  <script>
126
- function appendMessage(newContent) {
127
  var chatbox = document.getElementById('chatbox-container');
128
- var messages = document.getElementById('messages');
129
-
130
- messages.innerHTML += newContent;
131
-
132
- if (chatbox.scrollHeight - chatbox.scrollTop === chatbox.clientHeight) {
133
- chatbox.scrollTop = messages.scrollHeight;
134
- }
135
  }
136
 
137
- var newMessageContent = `""" + messages_html + """`;
138
- appendMessage(newMessageContent);
139
-
140
  window.onload = function() {
141
- var chatbox = document.getElementById('chatbox-container');
142
- var messages = document.getElementById('messages');
143
- chatbox.scrollTop = messages.scrollHeight; // Ensure it scrolls to the bottom on load
144
  };
 
 
145
  </script>
146
  """
147
 
 
105
  messages_html = """
106
  <div id="chatbox-container" class="chatbox">
107
  <div id="messages">"""
108
+
109
  for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
110
  if user_message:
111
  messages_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
 
124
  </div>
125
 
126
  <script>
127
+ function scrollToBottom() {
128
  var chatbox = document.getElementById('chatbox-container');
129
+ setTimeout(function() {
130
+ chatbox.scrollTop = chatbox.scrollHeight;
131
+ }, 500);
 
 
 
 
132
  }
133
 
 
 
 
134
  window.onload = function() {
135
+ scrollToBottom();
 
 
136
  };
137
+
138
+ scrollToBottom();
139
  </script>
140
  """
141