Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -102,9 +102,7 @@ def respond(message, api_key, max_tokens, top_p, temperature):
|
|
102 |
return history, "Error: " + response.json().get("error", "Unknown error occurred.")
|
103 |
|
104 |
def render_message(history):
|
105 |
-
messages_html = ""
|
106 |
-
<div id="chatbox-container" class="chatbox">
|
107 |
-
<div id="messages" style="scroll-behavior: smooth;">"""
|
108 |
|
109 |
for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
|
110 |
if user_message:
|
@@ -119,21 +117,28 @@ def render_message(history):
|
|
119 |
messages_html += f"<img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
|
120 |
messages_html += f"{assistant_message}</div><br>"
|
121 |
|
122 |
-
messages_html
|
123 |
-
|
124 |
-
|
|
|
125 |
<script>
|
|
|
|
|
126 |
var chatboxContainer = document.getElementById('chatbox-container');
|
127 |
chatboxContainer.scrollTop = chatboxContainer.scrollHeight;
|
128 |
</script>
|
129 |
-
"""
|
130 |
|
131 |
-
return messages_html
|
132 |
|
133 |
|
134 |
-
with gr.Blocks(
|
135 |
-
|
136 |
-
with gr.Column(
|
|
|
|
|
|
|
|
|
|
|
137 |
gr.Markdown("## P-MSQ Authorization")
|
138 |
gr.Markdown("P-MSQ is in closed alpha test! The model, api and more are subject to change. Even though the space is public, P-MSQ is restricted for public use, available for testers.")
|
139 |
api_user_input = gr.Textbox(placeholder="snowflake", label="UserID", type='email')
|
|
|
102 |
return history, "Error: " + response.json().get("error", "Unknown error occurred.")
|
103 |
|
104 |
def render_message(history):
|
105 |
+
messages_html = ""
|
|
|
|
|
106 |
|
107 |
for user_message, assistant_message, user_profile, assistant_profile, user_pic, assistant_pic in history:
|
108 |
if user_message:
|
|
|
117 |
messages_html += f"<img src='{assistant_pic}' style='width: 40px; height: 40px; border-radius: 50%; margin-right: 10px;'>"
|
118 |
messages_html += f"{assistant_message}</div><br>"
|
119 |
|
120 |
+
return messages_html
|
121 |
+
|
122 |
+
def append_new_message(new_message):
|
123 |
+
return f"""
|
124 |
<script>
|
125 |
+
var chatbox = document.getElementById('messages');
|
126 |
+
chatbox.innerHTML += `{new_message}`;
|
127 |
var chatboxContainer = document.getElementById('chatbox-container');
|
128 |
chatboxContainer.scrollTop = chatboxContainer.scrollHeight;
|
129 |
</script>
|
130 |
+
"""
|
131 |
|
|
|
132 |
|
133 |
|
134 |
+
with gr.Blocks() as demo:
|
135 |
+
|
136 |
+
with gr.Column():
|
137 |
+
chatbot_output = gr.HTML(elem_id="chatbox-container", value="""
|
138 |
+
<div id="chatbox-container" class="chatbox" style="height: 400px; overflow-y: auto; border: 1px solid #262626; padding: 10px; background-color: #171717;">
|
139 |
+
<div id="messages"></div>
|
140 |
+
</div>
|
141 |
+
""")
|
142 |
gr.Markdown("## P-MSQ Authorization")
|
143 |
gr.Markdown("P-MSQ is in closed alpha test! The model, api and more are subject to change. Even though the space is public, P-MSQ is restricted for public use, available for testers.")
|
144 |
api_user_input = gr.Textbox(placeholder="snowflake", label="UserID", type='email')
|