Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -187,17 +187,21 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow-y: auto; border: 1px solid
|
|
187 |
|
188 |
def authorize_and_proceed(user, api_key):
|
189 |
if authorize(user, api_key, PRIMARY_SYSTEM_INSTRUCTIONS):
|
|
|
190 |
messages_html, history = load_conversation(api_key)
|
191 |
return gr.update(visible=False), gr.update(visible=True), messages_html, history
|
192 |
else:
|
|
|
193 |
return gr.update(visible=True), gr.update(visible=False), auth_status.update(value="Invalid userid/token")
|
194 |
|
195 |
def save_custom_instructions(api_key, custom_instructions):
|
196 |
if api_key in sessions:
|
|
|
197 |
sessions[api_key]["system_message"] = custom_instructions
|
198 |
-
return "Instructions updated!"
|
199 |
else:
|
200 |
-
|
|
|
201 |
|
202 |
|
203 |
auth_button.click(authorize_and_proceed, inputs=[api_user_input, api_key_input], outputs=[auth_view, chat_view, chatbot_output, history_state])
|
|
|
187 |
|
188 |
def authorize_and_proceed(user, api_key):
|
189 |
if authorize(user, api_key, PRIMARY_SYSTEM_INSTRUCTIONS):
|
190 |
+
gr.Info("Loading, please wait.")
|
191 |
messages_html, history = load_conversation(api_key)
|
192 |
return gr.update(visible=False), gr.update(visible=True), messages_html, history
|
193 |
else:
|
194 |
+
gr.Warning("Incorrect userid/token")
|
195 |
return gr.update(visible=True), gr.update(visible=False), auth_status.update(value="Invalid userid/token")
|
196 |
|
197 |
def save_custom_instructions(api_key, custom_instructions):
|
198 |
if api_key in sessions:
|
199 |
+
gr.Info("Instructions updated, we recommend to start the new conversation to make it more efficient.")
|
200 |
sessions[api_key]["system_message"] = custom_instructions
|
201 |
+
return "Instructions updated!", gr.update(value="")
|
202 |
else:
|
203 |
+
gr.Warning("Your session has been expired, please refresh the page and login again.")
|
204 |
+
return "Session not found.", gr.update(value="")
|
205 |
|
206 |
|
207 |
auth_button.click(authorize_and_proceed, inputs=[api_user_input, api_key_input], outputs=[auth_view, chat_view, chatbot_output, history_state])
|