Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,21 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
return x, state, state
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
number = gr.Number(label="On release")
|
| 14 |
-
number2 = gr.Number(label="Number of events fired")
|
| 15 |
-
btn = gr.Button("RUN")
|
| 16 |
-
btn.click(identity, inputs=[slider, state], outputs=[number, state, number2], api_name="predict")
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
| 1 |
+
with gr.Blocks() as demo:
|
| 2 |
+
chatbot = gr.Chatbot()
|
| 3 |
+
msg = gr.Textbox()
|
| 4 |
+
clear = gr.Button("Clear")
|
| 5 |
|
| 6 |
+
def user(user_message, history):
|
| 7 |
+
return "", history + [[user_message, None]]
|
|
|
|
| 8 |
|
| 9 |
+
def bot(history):
|
| 10 |
+
bot_message = random.choice(["Yes", "No"])
|
| 11 |
+
history[-1][1] = bot_message
|
| 12 |
+
time.sleep(1)
|
| 13 |
+
return history
|
| 14 |
|
| 15 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
| 16 |
+
bot, chatbot, chatbot
|
| 17 |
+
)
|
| 18 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
demo.launch()
|