Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -133,9 +133,9 @@ def process_message(message, history):
|
|
| 133 |
# Gradio interface for the chatbot
|
| 134 |
def create_gradio_interface():
|
| 135 |
with gr.Blocks() as demo:
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
chatbot = gr.Chatbot([])
|
| 140 |
msg = gr.Textbox(show_label=False, placeholder="Enter text and press enter")
|
| 141 |
clear = gr.Button("Clear")
|
|
@@ -151,6 +151,11 @@ def create_gradio_interface():
|
|
| 151 |
history[-1][1] = bot_message
|
| 152 |
return history
|
| 153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
msg.submit(user, [msg, chatbot], [msg, chatbot]).then(bot, chatbot, chatbot)
|
| 155 |
clear.click(lambda: None, None, chatbot)
|
| 156 |
|
|
|
|
| 133 |
# Gradio interface for the chatbot
|
| 134 |
def create_gradio_interface():
|
| 135 |
with gr.Blocks() as demo:
|
| 136 |
+
category_btns = gr.Radio(choices=["Vegetarian", "Non-Vegetarian"], label="Select Category")
|
| 137 |
+
ingredient_btns = gr.Radio(choices=VEG_INGREDIENTS + NONVEG_TYPES, label="Select Ingredient")
|
| 138 |
+
nutrition_btns = gr.Radio(choices=NUTRITION_OPTIONS, label="Select Nutrition")
|
| 139 |
chatbot = gr.Chatbot([])
|
| 140 |
msg = gr.Textbox(show_label=False, placeholder="Enter text and press enter")
|
| 141 |
clear = gr.Button("Clear")
|
|
|
|
| 151 |
history[-1][1] = bot_message
|
| 152 |
return history
|
| 153 |
|
| 154 |
+
# Handle category selection and pass to the next steps
|
| 155 |
+
category_btns.change(lambda category: process_message(category, []), category_btns, chatbot)
|
| 156 |
+
ingredient_btns.change(lambda ingredient: process_message(ingredient, []), ingredient_btns, chatbot)
|
| 157 |
+
nutrition_btns.change(lambda nutrition: process_message(nutrition, []), nutrition_btns, chatbot)
|
| 158 |
+
|
| 159 |
msg.submit(user, [msg, chatbot], [msg, chatbot]).then(bot, chatbot, chatbot)
|
| 160 |
clear.click(lambda: None, None, chatbot)
|
| 161 |
|