Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -124,38 +124,10 @@ def render_message(history):
|
|
124 |
|
125 |
messages_html += "</div></div>"
|
126 |
|
127 |
-
scroll_script = """
|
128 |
-
<script>
|
129 |
-
const container = document.getElementById('chatbox-container');
|
130 |
-
|
131 |
-
const observer = new MutationObserver(() => {
|
132 |
-
container.scrollTop = container.scrollHeight; // Force scroll to bottom after re-render
|
133 |
-
});
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
window.onload = function() {
|
138 |
-
container.scrollTop = container.scrollHeight;
|
139 |
-
};
|
140 |
-
</script>
|
141 |
-
"""
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}",
|
146 |
-
js="""
|
147 |
-
function scrollToBottom() {
|
148 |
-
const container = document.getElementById('chatbox-container');
|
149 |
-
if (container) {
|
150 |
-
container.scrollTop = container.scrollHeight;
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
window.onload = scrollToBottom;
|
155 |
-
|
156 |
-
const observer = new MutationObserver(scrollToBottom);
|
157 |
-
observer.observe(document.getElementById('chatbox-container'), { childList: true, subtree: true });
|
158 |
-
""") as demo:
|
159 |
|
160 |
with gr.Column(visible=True) as auth_view:
|
161 |
gr.Markdown("## P-MSQ Authorization")
|
@@ -249,6 +221,23 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid
|
|
249 |
auth_button.click(authorize_and_proceed, inputs=[api_user_input, api_key_input], outputs=[auth_view, chat_view, chatbot_output, history_state])
|
250 |
save_instructions_btn.click(save_custom_instructions, inputs=[api_key_input, system_instructions_input], outputs=auth_status)
|
251 |
demo.load(lambda: None, [], None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
demo.launch()
|
253 |
if __name__ == "__main__":
|
254 |
demo.queue = False
|
|
|
124 |
|
125 |
messages_html += "</div></div>"
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
+
return messages_html
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
+
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
with gr.Column(visible=True) as auth_view:
|
133 |
gr.Markdown("## P-MSQ Authorization")
|
|
|
221 |
auth_button.click(authorize_and_proceed, inputs=[api_user_input, api_key_input], outputs=[auth_view, chat_view, chatbot_output, history_state])
|
222 |
save_instructions_btn.click(save_custom_instructions, inputs=[api_key_input, system_instructions_input], outputs=auth_status)
|
223 |
demo.load(lambda: None, [], None)
|
224 |
+
demo.append(gr.HTML("""
|
225 |
+
<script>
|
226 |
+
function scrollToBottom() {
|
227 |
+
const container = document.getElementById('chatbox-container');
|
228 |
+
if (container) {
|
229 |
+
container.scrollTop = container.scrollHeight;
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
// Scroll to bottom after the page has loaded
|
234 |
+
window.onload = scrollToBottom;
|
235 |
+
|
236 |
+
// Observe changes in the chatbox container to scroll on new messages
|
237 |
+
const observer = new MutationObserver(scrollToBottom);
|
238 |
+
observer.observe(document.getElementById('chatbox-container'), { childList: true, subtree: true });
|
239 |
+
</script>
|
240 |
+
"""))
|
241 |
demo.launch()
|
242 |
if __name__ == "__main__":
|
243 |
demo.queue = False
|