Spaces:
Sleeping
Sleeping
create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import random
|
| 3 |
+
|
| 4 |
+
def respond(message, history):
|
| 5 |
+
responses = ["Yes", "No"]
|
| 6 |
+
return random.choice(responses)
|
| 7 |
+
|
| 8 |
+
# 1. Create a custom chatbot component with a greeting
|
| 9 |
+
custom_chatbot = gr.Chatbot(
|
| 10 |
+
value=[{"role": "assistant", "content": "Hello! I am the Yes No Bot. Ask me anything!"}]
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
# 2. Pass it to the ChatInterface
|
| 14 |
+
chatbot = gr.ChatInterface(
|
| 15 |
+
respond,
|
| 16 |
+
title="Yes No Bot",
|
| 17 |
+
description="This chatbot responds yes or no to your questions!",
|
| 18 |
+
examples=["Will I win the lottery?", "Am I the drama?"],
|
| 19 |
+
chatbot=custom_chatbot # Inject the custom chatbot here
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
chatbot.launch(share=True, debug=True)
|