RomZay commited on
Commit
14bd6e3
·
verified ·
1 Parent(s): 57ccf2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -85,6 +85,31 @@ def respond(message, api_key, max_tokens, top_p, temperature):
85
  return history, "Error: " + response.json().get("error", "Unknown error occurred.")
86
 
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
  js = """
90
  function Scrolldown() {
 
85
  return history, "Error: " + response.json().get("error", "Unknown error occurred.")
86
 
87
 
88
+ def render_message(history):
89
+ messages_html = """
90
+ <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;">
91
+ <div id="messages">"""
92
+
93
+ for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
94
+ if user_message:
95
+ messages_html += f"""
96
+ <div style='display: flex; align-items: center; margin-bottom: 10px;'>
97
+ <img src='{user_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>
98
+ <span style='color: white;'><b>{user_profile}:</b></span>
99
+ <span style='color: white;'>{gr.Markdown(user_message)}</span>
100
+ </div><br>"""
101
+
102
+ if assistant_message:
103
+ messages_html += f"""
104
+ <div style='display: flex; align-items: center; margin-bottom: 10px;'>
105
+ <img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>
106
+ <span style='color: white;'><b>{assistant_profile}:</b></span>
107
+ <span style='color: white;'>{gr.Markdown(assistant_message)}</span>
108
+ </div><br>"""
109
+
110
+ messages_html += "</div></div>"
111
+ return messages_html
112
+
113
 
114
  js = """
115
  function Scrolldown() {