Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,4 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from flask import Flask, request, jsonify
|
| 3 |
-
|
| 4 |
-
# Flask app setup
|
| 5 |
-
app = Flask(__name__)
|
| 6 |
|
| 7 |
# Corrected Food Database with consistent food item names
|
| 8 |
FOOD_DATABASE = {
|
|
@@ -133,9 +129,9 @@ def process_message(message, history):
|
|
| 133 |
# Gradio interface for the chatbot
|
| 134 |
def create_gradio_interface():
|
| 135 |
with gr.Blocks() as demo:
|
| 136 |
-
category_btns = gr.
|
| 137 |
-
ingredient_btns = gr.
|
| 138 |
-
nutrition_btns = gr.
|
| 139 |
chatbot = gr.Chatbot([])
|
| 140 |
msg = gr.Textbox(show_label=False, placeholder="Enter text and press enter")
|
| 141 |
clear = gr.Button("Clear")
|
|
@@ -161,19 +157,6 @@ def create_gradio_interface():
|
|
| 161 |
|
| 162 |
return demo
|
| 163 |
|
| 164 |
-
# Flask route to process messages
|
| 165 |
-
@app.route("/process_message", methods=["POST"])
|
| 166 |
-
def process_message_from_js():
|
| 167 |
-
data = request.get_json()
|
| 168 |
-
message = data.get('message')
|
| 169 |
-
|
| 170 |
-
# Process the message using the existing process_message function
|
| 171 |
-
history = [] # You may pass the history if needed, but keep it simple for now
|
| 172 |
-
bot_response = process_message(message, history)
|
| 173 |
-
|
| 174 |
-
# Return the bot response as JSON
|
| 175 |
-
return jsonify({'response': bot_response})
|
| 176 |
-
|
| 177 |
if __name__ == "__main__":
|
| 178 |
# Create Gradio interface
|
| 179 |
demo = create_gradio_interface()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
# Corrected Food Database with consistent food item names
|
| 4 |
FOOD_DATABASE = {
|
|
|
|
| 129 |
# Gradio interface for the chatbot
|
| 130 |
def create_gradio_interface():
|
| 131 |
with gr.Blocks() as demo:
|
| 132 |
+
category_btns = gr.ButtonGroup(choices=["Vegetarian", "Non-Vegetarian"], label="Select Category")
|
| 133 |
+
ingredient_btns = gr.ButtonGroup(choices=VEG_INGREDIENTS + NONVEG_TYPES, label="Select Ingredient")
|
| 134 |
+
nutrition_btns = gr.ButtonGroup(choices=NUTRITION_OPTIONS, label="Select Nutrition")
|
| 135 |
chatbot = gr.Chatbot([])
|
| 136 |
msg = gr.Textbox(show_label=False, placeholder="Enter text and press enter")
|
| 137 |
clear = gr.Button("Clear")
|
|
|
|
| 157 |
|
| 158 |
return demo
|
| 159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
if __name__ == "__main__":
|
| 161 |
# Create Gradio interface
|
| 162 |
demo = create_gradio_interface()
|