RomZay commited on
Commit
52b5151
·
verified ·
1 Parent(s): 5a4637d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -105,23 +105,23 @@ 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" style="height: 350px; overflow-y: auto;"> <!-- Ensure the chatbox can scroll -->
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:
113
  messages_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
114
  if user_pic:
115
  messages_html += f"<img src='{user_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
116
- messages_html += f"{user_message}</div><br>"
117
 
118
  if assistant_message:
119
  messages_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
120
  if assistant_pic:
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
 
@@ -167,8 +167,15 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid
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>setTimeout(() => { document.getElementById('chatbox-container').scrollTop = document.getElementById('chatbox-container').scrollHeight; }, 0);</script>"
171
- return full_history_html + scroll_script, history, "", message
 
 
 
 
 
 
 
172
 
173
 
174
  def regenerate_response(history, last_message, max_tokens, top_p, temperature):
 
105
 
106
  def render_message(history):
107
  messages_html = """
108
+ <div id="chatbox-container" class="chatbox" style="height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;">
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:
113
  messages_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
114
  if user_pic:
115
  messages_html += f"<img src='{user_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
116
+ messages_html += f"<span style='color: white;'>{user_message}</span></div><br>"
117
 
118
  if assistant_message:
119
  messages_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
120
  if assistant_pic:
121
  messages_html += f"<img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
122
+ messages_html += f"<span style='color: white;'>{assistant_message}</span></div><br>"
123
 
124
+ messages_html += "</div></div>"
125
  return messages_html
126
 
127
 
 
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 = """
171
+ <script>
172
+ setTimeout(() => {
173
+ const container = document.getElementById('chatbox-container');
174
+ container.scrollTop = container.scrollHeight;
175
+ }, 0);
176
+ </script>"""
177
+
178
+ return full_history_html + scroll_script, history, "", message
179
 
180
 
181
  def regenerate_response(history, last_message, max_tokens, top_p, temperature):