RomZay commited on
Commit
1a5e59e
·
verified ·
1 Parent(s): 00deb4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -53,6 +53,8 @@ def authorize(user, api_key, system_message):
53
  "system_message": system_message
54
  }
55
  return True
 
 
56
  else:
57
  return False
58
  except Exception as e:
@@ -224,6 +226,11 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow: auto; border: 1px solid #
224
  inputs=[api_key_input],
225
  outputs=[chatbot_output, history_state])
226
 
 
 
 
 
 
227
  def authorize_and_proceed(user, api_key):
228
  if authorize(user, api_key, PRIMARY_SYSTEM_INSTRUCTIONS):
229
  gr.Info("Loading, please wait.")
@@ -235,6 +242,12 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow: auto; border: 1px solid #
235
  messages_html,
236
  history
237
  )
 
 
 
 
 
 
238
  else:
239
  gr.Warning("Incorrect userid/token")
240
  return (
@@ -252,6 +265,9 @@ with gr.Blocks(css=".chatbox {height: 400px; overflow: auto; border: 1px solid #
252
  gr.Warning("Your session has been expired, please refresh the page and login again.")
253
  return "Session not found.", gr.update(value="")
254
 
 
 
 
255
  auth_button.click(authorize_and_proceed, inputs=[api_user_input, api_key_input], outputs=[auth_view, chat_view, chatbot_output, history_state])
256
  save_instructions_btn.click(save_custom_instructions, inputs=[api_key_input, system_instructions_input], outputs=auth_status)
257
  demo.launch(show_api=False)
 
53
  "system_message": system_message
54
  }
55
  return True
56
+ elif response.status_code == 403:
57
+ return 403
58
  else:
59
  return False
60
  except Exception as e:
 
226
  inputs=[api_key_input],
227
  outputs=[chatbot_output, history_state])
228
 
229
+ with gr.Column(visible=False) as blacklist_view:
230
+ gr.Markdown("## P-MSQ Authorization")
231
+ gr.Markdown("Your linked ID appears to be blacklisted, and your API Key is pending on removal, if you believe this is a mistake, please try reaching us out.")
232
+
233
+
234
  def authorize_and_proceed(user, api_key):
235
  if authorize(user, api_key, PRIMARY_SYSTEM_INSTRUCTIONS):
236
  gr.Info("Loading, please wait.")
 
242
  messages_html,
243
  history
244
  )
245
+ elif authorize(user, api_key, PRIMARY_SYSTEM_INSTRUCTIONS) == 403:
246
+ return (
247
+ gr.update(visible=False),
248
+ gr.update(visible=False),
249
+ gr.update(visible=True),
250
+ )
251
  else:
252
  gr.Warning("Incorrect userid/token")
253
  return (
 
265
  gr.Warning("Your session has been expired, please refresh the page and login again.")
266
  return "Session not found.", gr.update(value="")
267
 
268
+
269
+
270
+
271
  auth_button.click(authorize_and_proceed, inputs=[api_user_input, api_key_input], outputs=[auth_view, chat_view, chatbot_output, history_state])
272
  save_instructions_btn.click(save_custom_instructions, inputs=[api_key_input, system_instructions_input], outputs=auth_status)
273
  demo.launch(show_api=False)