Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -168,8 +168,11 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow: auto; border: 1px solid #
|
|
168 |
last_message_state = gr.State("")
|
169 |
|
170 |
def user_interaction(message, history, api_key, max_tokens, top_p, temperature):
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
173 |
|
174 |
def regenerate_response(history, last_message, max_tokens, top_p, temperature):
|
175 |
return "", []
|
@@ -187,15 +190,13 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow: auto; border: 1px solid #
|
|
187 |
msg_input.submit(
|
188 |
user_interaction,
|
189 |
inputs=[msg_input, history_state, api_key_input, max_tokens, top_p, temperature],
|
190 |
-
outputs=[chatbot_output, history_state, msg_input
|
191 |
-
scroll_to_output=True
|
192 |
)
|
193 |
|
194 |
send_btn.click(
|
195 |
user_interaction,
|
196 |
inputs=[msg_input, history_state, api_key_input, max_tokens, top_p, temperature],
|
197 |
-
outputs=[chatbot_output, history_state, msg_input
|
198 |
-
scroll_to_output=True
|
199 |
)
|
200 |
|
201 |
regen_btn.click(clear_history,
|
@@ -211,8 +212,7 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow: auto; border: 1px solid #
|
|
211 |
gr.update(visible=False),
|
212 |
gr.update(visible=True),
|
213 |
messages_html,
|
214 |
-
history
|
215 |
-
gr.HTML("<script>Scrolldown();</script>")
|
216 |
)
|
217 |
else:
|
218 |
gr.Warning("Incorrect userid/token")
|
@@ -233,7 +233,6 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow: auto; border: 1px solid #
|
|
233 |
|
234 |
auth_button.click(authorize_and_proceed, inputs=[api_user_input, api_key_input], outputs=[auth_view, chat_view, chatbot_output, history_state])
|
235 |
save_instructions_btn.click(save_custom_instructions, inputs=[api_key_input, system_instructions_input], outputs=auth_status)
|
236 |
-
demo.load(lambda: None, [], None)
|
237 |
demo.launch()
|
238 |
if __name__ == "__main__":
|
239 |
demo.queue = False
|
|
|
168 |
last_message_state = gr.State("")
|
169 |
|
170 |
def user_interaction(message, history, api_key, max_tokens, top_p, temperature):
|
171 |
+
loading_message = history + [(message, "Loading...", "You", "P-ALPLE", USER_PIC_PATH, ASSISTANT_PIC_PATH)]
|
172 |
+
yield render_message(loading_message), loading_message, ""
|
173 |
+
|
174 |
+
history, assistant_reply = respond(message, api_key, max_tokens, top_p, temperature)
|
175 |
+
yield render_message(history), history, ""
|
176 |
|
177 |
def regenerate_response(history, last_message, max_tokens, top_p, temperature):
|
178 |
return "", []
|
|
|
190 |
msg_input.submit(
|
191 |
user_interaction,
|
192 |
inputs=[msg_input, history_state, api_key_input, max_tokens, top_p, temperature],
|
193 |
+
outputs=[chatbot_output, history_state, msg_input],
|
|
|
194 |
)
|
195 |
|
196 |
send_btn.click(
|
197 |
user_interaction,
|
198 |
inputs=[msg_input, history_state, api_key_input, max_tokens, top_p, temperature],
|
199 |
+
outputs=[chatbot_output, history_state, msg_input],
|
|
|
200 |
)
|
201 |
|
202 |
regen_btn.click(clear_history,
|
|
|
212 |
gr.update(visible=False),
|
213 |
gr.update(visible=True),
|
214 |
messages_html,
|
215 |
+
history
|
|
|
216 |
)
|
217 |
else:
|
218 |
gr.Warning("Incorrect userid/token")
|
|
|
233 |
|
234 |
auth_button.click(authorize_and_proceed, inputs=[api_user_input, api_key_input], outputs=[auth_view, chat_view, chatbot_output, history_state])
|
235 |
save_instructions_btn.click(save_custom_instructions, inputs=[api_key_input, system_instructions_input], outputs=auth_status)
|
|
|
236 |
demo.launch()
|
237 |
if __name__ == "__main__":
|
238 |
demo.queue = False
|