Spaces:
Sleeping
Sleeping
abhi12ravi
commited on
Commit
•
bd5cfd9
1
Parent(s):
6518f7c
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,35 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def my_chatbot(input, history):
|
|
|
4 |
|
5 |
+
history = history or []
|
6 |
+
|
7 |
+
my_history = list(sum(history, ()))
|
8 |
+
|
9 |
+
my_history.append(input)
|
10 |
+
|
11 |
+
my_input = ' '.join(my_history)
|
12 |
+
|
13 |
+
output = generate_response(input, history)
|
14 |
+
|
15 |
+
history.append((input, output))
|
16 |
+
|
17 |
+
return history, history
|
18 |
+
|
19 |
+
with gr.Blocks() as demo:
|
20 |
+
|
21 |
+
gr.Markdown("""<h1><center>My Chatbot</center></h1>""")
|
22 |
+
|
23 |
+
chatbot = gr.Chatbot()
|
24 |
+
|
25 |
+
state = gr.State()
|
26 |
+
|
27 |
+
text = gr.Textbox(placeholder="Hello. Ask me a question.")
|
28 |
+
|
29 |
+
submit = gr.Button("SEND")
|
30 |
+
|
31 |
+
submit.click(my_chatbot, inputs=[text, state], outputs=[chatbot, state])
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
demo.launch(debug=True)
|