nagasurendra commited on
Commit
e31d13b
·
verified ·
1 Parent(s): 95e8e30

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +5 -1
static/script.js CHANGED
@@ -52,6 +52,7 @@ function handleResponse(userInput) {
52
  } else if (lastMessage.includes('non-vegetarian') || lastMessage.includes('non veg') || lastMessage.includes('nonveg')) {
53
  conversation.push({ role: 'user', message: 'Non-Vegetarian' }); // Store Non-Vegetarian preference
54
  console.log("Food preference selected: Non-Vegetarian");
 
55
  botResponse = 'Great choice! 🍽️ We have some amazing non-vegetarian options! What\'s your dietary preference?';
56
  options = [
57
  { text: 'Low Carb', class: '' },
@@ -62,6 +63,7 @@ function handleResponse(userInput) {
62
  } else if (lastMessage.includes('vegetarian')) {
63
  conversation.push({ role: 'user', message: 'Vegetarian' }); // Store Vegetarian preference
64
  console.log("Food preference selected: Vegetarian");
 
65
  botResponse = 'Great choice! 🍽️ We have some amazing vegetarian options! What\'s your dietary preference?';
66
  options = [
67
  { text: 'Vegan', class: '' },
@@ -73,7 +75,8 @@ function handleResponse(userInput) {
73
  ];
74
  } else if (lastMessage.includes('low carb') || lastMessage.includes('dairy-free') || lastMessage.includes('keto') || lastMessage.includes('halal') || lastMessage.includes('gluten-free') || lastMessage.includes('vegan') || lastMessage.includes('vegetarian')) {
75
  // Fetch ingredients based on previous food preference (Vegetarian or Non-Vegetarian)
76
- const foodPreference = conversation.find(msg => msg.role === 'user' && (msg.message.includes('vegetarian') || msg.message.includes('non-vegetarian')))?.message.toLowerCase();
 
77
 
78
  console.log("Previous food preference: " + foodPreference); // Debug which food preference is selected
79
 
@@ -95,6 +98,7 @@ function handleResponse(userInput) {
95
 
96
 
97
 
 
98
  function fetchIngredients(foodPreference) {
99
  fetch('/get_ingredients', {
100
  method: 'POST',
 
52
  } else if (lastMessage.includes('non-vegetarian') || lastMessage.includes('non veg') || lastMessage.includes('nonveg')) {
53
  conversation.push({ role: 'user', message: 'Non-Vegetarian' }); // Store Non-Vegetarian preference
54
  console.log("Food preference selected: Non-Vegetarian");
55
+ console.log("Conversation Array after storing Non-Vegetarian:", conversation); // Debugging: Log conversation
56
  botResponse = 'Great choice! 🍽️ We have some amazing non-vegetarian options! What\'s your dietary preference?';
57
  options = [
58
  { text: 'Low Carb', class: '' },
 
63
  } else if (lastMessage.includes('vegetarian')) {
64
  conversation.push({ role: 'user', message: 'Vegetarian' }); // Store Vegetarian preference
65
  console.log("Food preference selected: Vegetarian");
66
+ console.log("Conversation Array after storing Vegetarian:", conversation); // Debugging: Log conversation
67
  botResponse = 'Great choice! 🍽️ We have some amazing vegetarian options! What\'s your dietary preference?';
68
  options = [
69
  { text: 'Vegan', class: '' },
 
75
  ];
76
  } else if (lastMessage.includes('low carb') || lastMessage.includes('dairy-free') || lastMessage.includes('keto') || lastMessage.includes('halal') || lastMessage.includes('gluten-free') || lastMessage.includes('vegan') || lastMessage.includes('vegetarian')) {
77
  // Fetch ingredients based on previous food preference (Vegetarian or Non-Vegetarian)
78
+ console.log("Conversation Array before finding food preference:", conversation); // Debugging
79
+ const foodPreference = conversation.find(msg => msg.role === 'user' && (msg.message.toLowerCase().includes('vegetarian') || msg.message.toLowerCase().includes('non-vegetarian')))?.message.toLowerCase();
80
 
81
  console.log("Previous food preference: " + foodPreference); // Debug which food preference is selected
82
 
 
98
 
99
 
100
 
101
+
102
  function fetchIngredients(foodPreference) {
103
  fetch('/get_ingredients', {
104
  method: 'POST',