Subbu1304 commited on
Commit
6dd2598
·
verified ·
1 Parent(s): fc0daf6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -57,6 +57,7 @@ class ChatState:
57
  self.step = "initial"
58
  self.category = ""
59
  self.ingredient = ""
 
60
 
61
  chat_state = ChatState()
62
 
@@ -75,7 +76,7 @@ def process_message(message, history):
75
  return f"Great! What main ingredient would you like? Available options: {', '.join(VEG_INGREDIENTS)}"
76
  elif "non-vegetarian" in message.lower():
77
  return f"Great! What type of meat would you prefer? Available options: {', '.join(NONVEG_TYPES)}"
78
- return "Please select either Vegetarian, Non-Vegetarian"
79
 
80
  elif chat_state.step == "ingredient":
81
  chat_state.ingredient = message.lower()
@@ -83,12 +84,12 @@ def process_message(message, history):
83
  return f"Perfect! Now, select your nutrition preference: {', '.join(NUTRITION_OPTIONS)}"
84
 
85
  elif chat_state.step == "nutrition":
86
- nutrition = message.lower().replace(" ", "")
87
  category = "nonveg" if "non" in chat_state.category else "veg"
88
  ingredient = chat_state.ingredient
89
 
90
  try:
91
- food_items = FOOD_DATABASE[category][ingredient][nutrition]
92
  response = f"Here are some {message} {ingredient} dishes for you:\n"
93
  for item in food_items:
94
  response += f"\n• {item['name']} ({item['calories']} cal, {item['protein']}g protein)\n {item['description']}"
@@ -100,6 +101,7 @@ def process_message(message, history):
100
 
101
  return "I'm not sure how to help with that. Would you like to start over?"
102
 
 
103
  def create_gradio_interface():
104
  with gr.Blocks() as demo:
105
  chatbot = gr.Chatbot([])
 
57
  self.step = "initial"
58
  self.category = ""
59
  self.ingredient = ""
60
+ self.nutrition = ""
61
 
62
  chat_state = ChatState()
63
 
 
76
  return f"Great! What main ingredient would you like? Available options: {', '.join(VEG_INGREDIENTS)}"
77
  elif "non-vegetarian" in message.lower():
78
  return f"Great! What type of meat would you prefer? Available options: {', '.join(NONVEG_TYPES)}"
79
+ return "Please select either Vegetarian or Non-Vegetarian."
80
 
81
  elif chat_state.step == "ingredient":
82
  chat_state.ingredient = message.lower()
 
84
  return f"Perfect! Now, select your nutrition preference: {', '.join(NUTRITION_OPTIONS)}"
85
 
86
  elif chat_state.step == "nutrition":
87
+ chat_state.nutrition = message.lower().replace(" ", "")
88
  category = "nonveg" if "non" in chat_state.category else "veg"
89
  ingredient = chat_state.ingredient
90
 
91
  try:
92
+ food_items = FOOD_DATABASE[category][ingredient][chat_state.nutrition]
93
  response = f"Here are some {message} {ingredient} dishes for you:\n"
94
  for item in food_items:
95
  response += f"\n• {item['name']} ({item['calories']} cal, {item['protein']}g protein)\n {item['description']}"
 
101
 
102
  return "I'm not sure how to help with that. Would you like to start over?"
103
 
104
+ # Gradio interface for the chatbot
105
  def create_gradio_interface():
106
  with gr.Blocks() as demo:
107
  chatbot = gr.Chatbot([])