RomZay commited on
Commit
a47df97
·
verified ·
1 Parent(s): 043d5a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -86,24 +86,25 @@ def respond(message, api_key, max_tokens, top_p, temperature):
86
 
87
  def render_message(history):
88
  messages_html = """
89
- <div id="chatbox-container" class="chatbox" style=".chatbox height: 400px; overflow: auto; border: 1px solid #262626; padding: 10px; background-color: #171717; display: flex; flex-direction: column-reverse;">
90
  <div id="messages">"""
91
 
92
  for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
93
  if user_message:
94
- messages_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
95
- if user_pic:
96
- messages_html += f"<img src='{user_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
97
- messages_html += f"<span style='color: white;'>{user_message}</span></div><br>"
 
98
 
99
  if assistant_message:
100
- messages_html += f"<div style='display: flex; align-items: center; margin-bottom: 10px;'>"
101
- if assistant_pic:
102
- messages_html += f"<img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
103
- messages_html += f"<span style='color: white;'>{assistant_message}</span></div><br>"
 
104
 
105
  messages_html += "</div></div>"
106
- messages_html += "<script>Scrolldown();</script>"
107
  return messages_html
108
 
109
  js = """
@@ -142,7 +143,7 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow: auto; border: 1px solid #
142
  with gr.Column(visible=False) as chat_view:
143
  gr.Markdown("## P-MSQ Chat Interface")
144
 
145
- chatbot_output = gr.Markdown()
146
 
147
  msg_input = gr.Textbox(
148
  show_label=False,
 
86
 
87
  def render_message(history):
88
  messages_html = """
89
+ <div id="chatbox-container" class="chatbox" style="height: 400px; overflow: auto; border: 1px solid #262626; padding: 10px; background-color: #171717; display: flex; flex-direction: column-reverse;">
90
  <div id="messages">"""
91
 
92
  for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
93
  if user_message:
94
+ messages_html += f"""
95
+ <div style='display: flex; align-items: center; margin-bottom: 10px;'>
96
+ <img src='{user_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>
97
+ <span style='color: white;'>**{user_profile}**: {user_message}</span>
98
+ </div><br>"""
99
 
100
  if assistant_message:
101
+ messages_html += f"""
102
+ <div style='display: flex; align-items: center; margin-bottom: 10px;'>
103
+ <img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>
104
+ <span style='color: white;'>**{assistant_profile}**: {assistant_message}</span>
105
+ </div><br>"""
106
 
107
  messages_html += "</div></div>"
 
108
  return messages_html
109
 
110
  js = """
 
143
  with gr.Column(visible=False) as chat_view:
144
  gr.Markdown("## P-MSQ Chat Interface")
145
 
146
+ chatbot_output = gr.HTML(elem_id="chatbox-container")
147
 
148
  msg_input = gr.Textbox(
149
  show_label=False,