Ali Abid commited on
Commit
e29f6c4
Β·
1 Parent(s): eb115f5
Files changed (2) hide show
  1. README.md +3 -3
  2. run.py +39 -0
README.md CHANGED
@@ -1,11 +1,11 @@
1
  ---
2
  title: Chatbot Test
3
- emoji: πŸŒ–
4
- colorFrom: red
5
  colorTo: yellow
6
  sdk: gradio
7
  sdk_version: 3.24.1
8
- app_file: app.py
9
  pinned: false
10
  license: mit
11
  ---
 
1
  ---
2
  title: Chatbot Test
3
+ emoji: πŸ’¬
4
+ colorFrom: blue
5
  colorTo: yellow
6
  sdk: gradio
7
  sdk_version: 3.24.1
8
+ app_file: run.py
9
  pinned: false
10
  license: mit
11
  ---
run.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time
3
+
4
+ def add_text(history, text):
5
+ history = history + [(text, None)]
6
+ return history, ""
7
+
8
+ def add_file(history, file):
9
+ history = history + [((file.name,), None)]
10
+ return history
11
+
12
+ def bot(history):
13
+ response = "That's amazing!"
14
+ for index, _ in enumerate(response):
15
+ history[-1][1] = response[:index + 1]
16
+ time.sleep(0.1)
17
+ yield history
18
+
19
+ with gr.Blocks() as demo:
20
+ chatbot = gr.Chatbot([], elem_id="chatbot")
21
+
22
+ with gr.Row():
23
+ with gr.Column(scale=0.85):
24
+ txt = gr.Textbox(
25
+ show_label=False,
26
+ placeholder="Enter text and press enter, or upload an image",
27
+ ).style(container=False)
28
+ with gr.Column(scale=0.15, min_width=0):
29
+ btn = gr.UploadButton("πŸ“", file_types=["image", "video", "audio"])
30
+
31
+ txt.submit(add_text, [chatbot, txt], [chatbot, txt]).then(
32
+ bot, chatbot, chatbot
33
+ )
34
+ btn.upload(add_file, [chatbot, btn], [chatbot]).then(
35
+ bot, chatbot, chatbot
36
+ )
37
+
38
+ if __name__ == "__main__":
39
+ demo.queue().launch()