Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -105,8 +105,8 @@ def respond(message, api_key, max_tokens, top_p, temperature):
|
|
105 |
|
106 |
def render_message(history):
|
107 |
messages_html = """
|
108 |
-
<div id="chatbox-container" class="chatbox">
|
109 |
-
<div id="messages">"""
|
110 |
|
111 |
for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
|
112 |
if user_message:
|
@@ -121,10 +121,11 @@ def render_message(history):
|
|
121 |
messages_html += f"<img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
|
122 |
messages_html += f"{assistant_message}</div><br>"
|
123 |
|
124 |
-
|
125 |
return messages_html
|
126 |
|
127 |
|
|
|
128 |
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}") as demo:
|
129 |
|
130 |
with gr.Column(visible=True) as auth_view:
|
@@ -166,7 +167,8 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid
|
|
166 |
def user_interaction(message, history, api_key, max_tokens, top_p, temperature):
|
167 |
history, assistant_reply = respond(message, api_key, max_tokens, top_p, temperature)
|
168 |
full_history_html = render_message(history)
|
169 |
-
|
|
|
170 |
|
171 |
def regenerate_response(history, last_message, max_tokens, top_p, temperature):
|
172 |
return "", []
|
@@ -219,4 +221,4 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid
|
|
219 |
|
220 |
if __name__ == "__main__":
|
221 |
demo.queue = False
|
222 |
-
demo.launch(
|
|
|
105 |
|
106 |
def render_message(history):
|
107 |
messages_html = """
|
108 |
+
<div id="chatbox-container" class="chatbox" style="height: 350px; overflow-y: auto;"> <!-- Set fixed height for scrolling -->
|
109 |
+
<div id="messages">""" # This will contain the messages
|
110 |
|
111 |
for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
|
112 |
if user_message:
|
|
|
121 |
messages_html += f"<img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
|
122 |
messages_html += f"{assistant_message}</div><br>"
|
123 |
|
124 |
+
messages_html += "</div></div>" # Close the messages and chatbox container
|
125 |
return messages_html
|
126 |
|
127 |
|
128 |
+
|
129 |
with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;}") as demo:
|
130 |
|
131 |
with gr.Column(visible=True) as auth_view:
|
|
|
167 |
def user_interaction(message, history, api_key, max_tokens, top_p, temperature):
|
168 |
history, assistant_reply = respond(message, api_key, max_tokens, top_p, temperature)
|
169 |
full_history_html = render_message(history)
|
170 |
+
scroll_script = "<script>document.getElementById('chatbox-container').scrollTop = document.getElementById('chatbox-container').scrollHeight;</script>"
|
171 |
+
return full_history_html + scroll_script, history, "", message
|
172 |
|
173 |
def regenerate_response(history, last_message, max_tokens, top_p, temperature):
|
174 |
return "", []
|
|
|
221 |
|
222 |
if __name__ == "__main__":
|
223 |
demo.queue = False
|
224 |
+
demo.launch()
|