lgaleana commited on
Commit
0646af4
1 Parent(s): 77424a9

Add gradio chatbot

Browse files
Files changed (2) hide show
  1. gradio_app.py +23 -0
  2. requirements.txt +3 -0
gradio_app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ import time
4
+ from typing import List
5
+
6
+
7
+ with gr.Blocks() as demo:
8
+ chatbot = gr.Chatbot()
9
+ msg = gr.Textbox()
10
+ clear = gr.Button("Clear")
11
+
12
+ def respond(message: str, chat_history: List):
13
+ print(type(message))
14
+ print(type(chat_history))
15
+ bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
16
+ chat_history.append((message, bot_message))
17
+ time.sleep(1)
18
+ return "", chat_history
19
+
20
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
21
+ clear.click(lambda: None, None, chatbot, queue=False)
22
+
23
+ demo.launch()
requirements.txt CHANGED
@@ -1,4 +1,7 @@
1
  beautifulsoup4
 
2
  openai
 
 
3
  python-dotenv
4
  requests==2.28.1
 
1
  beautifulsoup4
2
+ gradio
3
  openai
4
+ pillow
5
+ protobuf
6
  python-dotenv
7
  requests==2.28.1