RamAnanth1 commited on
Commit
f59e6b8
·
1 Parent(s): 315197f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -13
app.py CHANGED
@@ -413,24 +413,16 @@ class ConversationBot:
413
  state = state + [(f"![](/file={image_filename})*{image_filename}*", AI_prompt)]
414
  print("Outputs:", state)
415
  return state, state, txt + ' ' + image_filename + ' '
416
-
417
-
418
- def init_conversation_bot(api_key):
419
- global bot
420
- bot = ConversationBot(api_key)
421
- return gr.update(visible = True)
422
 
423
- bot = None
424
- #bot = ConversationBot()
425
  with gr.Blocks(css="#chatbot .overflow-y-auto{height:500px}") as demo:
426
- openai_api_key = gr.Textbox(type='password', label="Enter your OpenAI API key here")
427
-
428
-
429
  chatbot = gr.Chatbot(elem_id="chatbot", label="Visual ChatGPT")
430
  state = gr.State([])
431
 
432
 
433
- with gr.Row(visible = False) as input_row:
434
  with gr.Column(scale=0.7):
435
  txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter, or upload an image").style(container=False)
436
  with gr.Column(scale=0.15, min_width=0):
@@ -438,7 +430,6 @@ with gr.Blocks(css="#chatbot .overflow-y-auto{height:500px}") as demo:
438
  with gr.Column(scale=0.15, min_width=0):
439
  btn = gr.UploadButton("Upload", file_types=["image"])
440
 
441
- openai_api_key.submit(init_conversation_bot,[openai_api_key],[input_row])
442
  txt.submit(bot.run_text, [txt, state], [chatbot, state])
443
  txt.submit(lambda: "", None, txt)
444
  btn.upload(bot.run_image, [btn, state, txt], [chatbot, state, txt])
 
413
  state = state + [(f"![](/file={image_filename})*{image_filename}*", AI_prompt)]
414
  print("Outputs:", state)
415
  return state, state, txt + ' ' + image_filename + ' '
 
 
 
 
 
 
416
 
417
+
418
+ bot = ConversationBot()
419
  with gr.Blocks(css="#chatbot .overflow-y-auto{height:500px}") as demo:
420
+
 
 
421
  chatbot = gr.Chatbot(elem_id="chatbot", label="Visual ChatGPT")
422
  state = gr.State([])
423
 
424
 
425
+ with gr.Row(visible = True) as input_row:
426
  with gr.Column(scale=0.7):
427
  txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter, or upload an image").style(container=False)
428
  with gr.Column(scale=0.15, min_width=0):
 
430
  with gr.Column(scale=0.15, min_width=0):
431
  btn = gr.UploadButton("Upload", file_types=["image"])
432
 
 
433
  txt.submit(bot.run_text, [txt, state], [chatbot, state])
434
  txt.submit(lambda: "", None, txt)
435
  btn.upload(bot.run_image, [btn, state, txt], [chatbot, state, txt])