Navyabhat commited on
Commit
ccfe396
·
verified ·
1 Parent(s): 86aa17d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -28
app.py CHANGED
@@ -13,34 +13,6 @@ multimodal_phi2 = MultiModalPhi2(
13
  # Initialize chatbot history
14
  messages = []
15
 
16
- # UI setup
17
- with gr.Blocks() as demo:
18
- chatbot = gr.Chatbot(
19
- [],
20
- elem_id="chatbot",
21
- bubble_full_width=False,
22
- avatar_images=(None, None), # You can specify avatar images if needed
23
- )
24
-
25
- with gr.Row():
26
- txt = gr.Textbox(
27
- scale=4,
28
- show_label=False,
29
- placeholder="Enter text and press enter, or upload an image",
30
- container=False,
31
- )
32
- btn = gr.UploadButton("📁", file_types=["image", "video", "audio"])
33
-
34
- txt_msg = txt.submit(add_content, [chatbot, txt], [chatbot, txt], queue=False).then(
35
- run, [chatbot, txt, None, None, None], [chatbot, txt, None, None, None], api_name="bot_response"
36
- )
37
- txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
38
- file_msg = btn.upload(add_content, [chatbot, None, None, btn, None], [chatbot, None, None, None], queue=False).then(
39
- run, [chatbot, None, None, None, btn], [chatbot, None, None, None, None]
40
- )
41
-
42
- chatbot.like(print_like_dislike, None, None)
43
-
44
  # Function to add content to chatbot
45
  def add_content(chatbot, text, image, audio_upload, audio_mic) -> gr.Chatbot:
46
  textflag, imageflag, audioflag = False, False, False
@@ -84,6 +56,36 @@ def run(history, text, image, audio_upload, audio_mic):
84
 
85
  history.append((None, outputs.title()))
86
  return history, None, None, None, None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  # Launch the Gradio UI
89
  demo.queue()
 
13
  # Initialize chatbot history
14
  messages = []
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  # Function to add content to chatbot
17
  def add_content(chatbot, text, image, audio_upload, audio_mic) -> gr.Chatbot:
18
  textflag, imageflag, audioflag = False, False, False
 
56
 
57
  history.append((None, outputs.title()))
58
  return history, None, None, None, None
59
+
60
+ # UI setup
61
+ with gr.Blocks() as demo:
62
+ chatbot = gr.Chatbot(
63
+ [],
64
+ elem_id="chatbot",
65
+ bubble_full_width=False,
66
+ avatar_images=(None, None), # You can specify avatar images if needed
67
+ )
68
+
69
+ with gr.Row():
70
+ txt = gr.Textbox(
71
+ scale=4,
72
+ show_label=False,
73
+ placeholder="Enter text and press enter, or upload an image",
74
+ container=False,
75
+ )
76
+ btn = gr.UploadButton("📁", file_types=["image", "video", "audio"])
77
+
78
+ txt_msg = txt.submit(add_content, [chatbot, txt], [chatbot, txt], queue=False).then(
79
+ run, [chatbot, txt, None, None, None], [chatbot, txt, None, None, None], api_name="bot_response"
80
+ )
81
+ txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
82
+ file_msg = btn.upload(add_content, [chatbot, None, None, btn, None], [chatbot, None, None, None], queue=False).then(
83
+ run, [chatbot, None, None, None, btn], [chatbot, None, None, None, None]
84
+ )
85
+
86
+ chatbot.like(print_like_dislike, None, None)
87
+
88
+
89
 
90
  # Launch the Gradio UI
91
  demo.queue()