Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -104,7 +104,7 @@ def respond(message, api_key, max_tokens, top_p, temperature):
|
|
104 |
def render_message(history):
|
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:
|
@@ -124,18 +124,28 @@ def render_message(history):
|
|
124 |
</div>
|
125 |
|
126 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
function scrollToBottom() {
|
128 |
var chatbox = document.getElementById('chatbox-container');
|
129 |
-
|
130 |
-
chatbox.scrollTop = chatbox.scrollHeight;
|
131 |
-
}, 500);
|
132 |
}
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
137 |
|
138 |
-
scrollToBottom();
|
139 |
</script>
|
140 |
"""
|
141 |
|
|
|
104 |
def render_message(history):
|
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:
|
|
|
124 |
</div>
|
125 |
|
126 |
<script>
|
127 |
+
function saveScrollPosition() {
|
128 |
+
var chatbox = document.getElementById('chatbox-container');
|
129 |
+
return chatbox.scrollTop;
|
130 |
+
}
|
131 |
+
|
132 |
+
function restoreScrollPosition(scrollPosition) {
|
133 |
+
var chatbox = document.getElementById('chatbox-container');
|
134 |
+
chatbox.scrollTop = scrollPosition;
|
135 |
+
}
|
136 |
+
|
137 |
function scrollToBottom() {
|
138 |
var chatbox = document.getElementById('chatbox-container');
|
139 |
+
chatbox.scrollTop = chatbox.scrollHeight;
|
|
|
|
|
140 |
}
|
141 |
|
142 |
+
var previousScrollPosition = saveScrollPosition();
|
143 |
+
|
144 |
+
setTimeout(function() {
|
145 |
+
restoreScrollPosition(previousScrollPosition);
|
146 |
+
scrollToBottom();
|
147 |
+
}, 100);
|
148 |
|
|
|
149 |
</script>
|
150 |
"""
|
151 |
|