POLRAMBORA commited on
Commit
75baf66
·
verified ·
1 Parent(s): 2b4f235

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -13
app.py CHANGED
@@ -269,30 +269,32 @@ with gr.Blocks(css=css) as demo:
269
 
270
 
271
  def authorize_and_proceed(user, api_key):
272
- if authorize(user, api_key, PRIMARY_SYSTEM_INSTRUCTIONS):
273
- gr.Info("Loading, please wait.")
274
- messages_html, history = load_conversation(api_key)
275
 
 
276
  return (
277
- gr.update(visible=False),
278
- gr.update(visible=True),
279
- messages_html,
280
- history
281
  )
282
- elif authorize(user, api_key, PRIMARY_SYSTEM_INSTRUCTIONS) == 403:
 
 
283
  return (
284
  gr.update(visible=False),
285
- gr.update(visible=False),
286
- gr.update(visible=True),
 
287
  )
288
  else:
289
- gr.Warning("Incorrect userid/token")
290
  return (
291
  gr.update(visible=True),
292
- gr.update(visible=False),
293
- auth_status.update(value="Invalid userid/token")
294
  )
295
 
 
296
  def save_custom_instructions(api_key, custom_instructions):
297
  if api_key in sessions:
298
  gr.Info("Instructions updated, we recommend to start the new conversation to make it more efficient.")
 
269
 
270
 
271
  def authorize_and_proceed(user, api_key):
272
+ auth_result = authorize(user, api_key, PRIMARY_SYSTEM_INSTRUCTIONS)
 
 
273
 
274
+ if auth_result == 403:
275
  return (
276
+ gr.update(visible=False),
277
+ gr.update(visible=False),
278
+ gr.update(visible=False),
279
+ gr.update(visible=True),
280
  )
281
+ elif auth_result:
282
+ gr.Info("Loading, please wait.")
283
+ messages_html, history = load_conversation(api_key)
284
  return (
285
  gr.update(visible=False),
286
+ gr.update(visible=True),
287
+ messages_html,
288
+ history
289
  )
290
  else:
 
291
  return (
292
  gr.update(visible=True),
293
+ gr.update(visible=False),
294
+ gr.update(value="Invalid userid/token"),
295
  )
296
 
297
+
298
  def save_custom_instructions(api_key, custom_instructions):
299
  if api_key in sessions:
300
  gr.Info("Instructions updated, we recommend to start the new conversation to make it more efficient.")