mihalykiss commited on
Commit
8fec267
·
verified ·
1 Parent(s): 079ae5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -197,7 +197,8 @@ def format_markdown(text):
197
  class ConversationState:
198
  def __init__(self):
199
  self.reset()
200
-
 
201
  def reset(self):
202
  self.current_step = "greeting"
203
  self.user_profile = {
@@ -211,6 +212,7 @@ class ConversationState:
211
  "restrictions": [],
212
  "allergies": []
213
  }
 
214
 
215
 
216
  session_states = {}
@@ -433,9 +435,11 @@ def chat_with_diet_bot(message, history, session_id=None):
433
 
434
  Generate a complete meal plan with:
435
  1. Diet Overview - Brief summary of the diet approach
436
- 2. Weekly Meal Plan - Day-by-day plan with breakfast, lunch, dinner, and snacks. Add calories and macros for each day!
437
  3. General Recommendations - Additional advice and nutrition tips
438
 
 
 
439
  Format in Markdown with clear headers and bullet points.
440
  """
441
 
@@ -448,9 +452,9 @@ def chat_with_diet_bot(message, history, session_id=None):
448
  ).generations[0].text
449
 
450
  formatted_response = format_markdown(cohere_response)
 
451
  response = formatted_response + "\n\nI hope this meal plan helps you achieve your goals! Feel free to ask if you have any nutrition questions."
452
  state.current_step = "diet_questions"
453
- GIVEN_DIET = response
454
 
455
  except Exception:
456
  response = "I'm sorry, I couldn't generate a diet plan at the moment. Please try again later."
@@ -480,7 +484,7 @@ def chat_with_diet_bot(message, history, session_id=None):
480
  prompt = f"""
481
  Answer this nutrition question clearly and accurately:
482
  Question: {message}
483
- Previous given diet: {GIVEN_DIET}
484
  Provide helpful, evidence-based advice with practical tips.
485
  """
486
 
 
197
  class ConversationState:
198
  def __init__(self):
199
  self.reset()
200
+ self.given_diet = ""
201
+
202
  def reset(self):
203
  self.current_step = "greeting"
204
  self.user_profile = {
 
212
  "restrictions": [],
213
  "allergies": []
214
  }
215
+ self.given_diet = ""
216
 
217
 
218
  session_states = {}
 
435
 
436
  Generate a complete meal plan with:
437
  1. Diet Overview - Brief summary of the diet approach
438
+ 2. Weekly Meal Plan - Day-by-day plan with breakfast, lunch, dinner, and snacks (sometimes).
439
  3. General Recommendations - Additional advice and nutrition tips
440
 
441
+ For every day, give an estimated calories and protein value!
442
+
443
  Format in Markdown with clear headers and bullet points.
444
  """
445
 
 
452
  ).generations[0].text
453
 
454
  formatted_response = format_markdown(cohere_response)
455
+ state.given_diet = formatted_response
456
  response = formatted_response + "\n\nI hope this meal plan helps you achieve your goals! Feel free to ask if you have any nutrition questions."
457
  state.current_step = "diet_questions"
 
458
 
459
  except Exception:
460
  response = "I'm sorry, I couldn't generate a diet plan at the moment. Please try again later."
 
484
  prompt = f"""
485
  Answer this nutrition question clearly and accurately:
486
  Question: {message}
487
+ Previous given diet: {state.given_diet}
488
  Provide helpful, evidence-based advice with practical tips.
489
  """
490