Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +6 -0
static/script.js
CHANGED
@@ -51,6 +51,7 @@ function handleResponse(userInput) {
|
|
51 |
];
|
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 |
botResponse = 'Great choice! 🍽️ We have some amazing non-vegetarian options! What\'s your dietary preference?';
|
55 |
options = [
|
56 |
{ text: 'Low Carb', class: '' },
|
@@ -60,6 +61,7 @@ function handleResponse(userInput) {
|
|
60 |
];
|
61 |
} else if (lastMessage.includes('vegetarian')) {
|
62 |
conversation.push({ role: 'user', message: 'Vegetarian' }); // Store Vegetarian preference
|
|
|
63 |
botResponse = 'Great choice! 🍽️ We have some amazing vegetarian options! What\'s your dietary preference?';
|
64 |
options = [
|
65 |
{ text: 'Vegan', class: '' },
|
@@ -73,9 +75,13 @@ function handleResponse(userInput) {
|
|
73 |
// Fetch ingredients based on previous food preference (Vegetarian or Non-Vegetarian)
|
74 |
const foodPreference = conversation.find(msg => msg.role === 'user' && (msg.message.includes('vegetarian') || msg.message.includes('non-vegetarian')))?.message.toLowerCase();
|
75 |
|
|
|
|
|
76 |
if (foodPreference === 'vegetarian') {
|
|
|
77 |
fetchIngredients('veg'); // Fetch Vegetarian ingredients
|
78 |
} else if (foodPreference === 'non-vegetarian') {
|
|
|
79 |
fetchIngredients('non-vegetarian'); // Fetch Non-Vegetarian ingredients
|
80 |
}
|
81 |
return; // Exit early to fetch ingredients
|
|
|
51 |
];
|
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: '' },
|
|
|
61 |
];
|
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: '' },
|
|
|
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 |
+
|
80 |
if (foodPreference === 'vegetarian') {
|
81 |
+
console.log("Fetching Vegetarian ingredients..."); // Debug when fetching vegetarian ingredients
|
82 |
fetchIngredients('veg'); // Fetch Vegetarian ingredients
|
83 |
} else if (foodPreference === 'non-vegetarian') {
|
84 |
+
console.log("Fetching Non-Vegetarian ingredients..."); // Debug when fetching non-vegetarian ingredients
|
85 |
fetchIngredients('non-vegetarian'); // Fetch Non-Vegetarian ingredients
|
86 |
}
|
87 |
return; // Exit early to fetch ingredients
|