Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +7 -7
static/script.js
CHANGED
|
@@ -52,13 +52,13 @@ function handleResponse(userInput) {
|
|
| 52 |
botResponse = 'Great choice! 🍽️ Fetching non-vegetarian ingredients...';
|
| 53 |
fetchIngredients('non-vegetarian');
|
| 54 |
} else if (selectedIngredients.length > 0 && lastMessage === 'suggest') {
|
| 55 |
-
botResponse = 'Generating
|
| 56 |
getFoodSuggestions();
|
| 57 |
} else if (lastMessage === 'done') {
|
| 58 |
-
botResponse = 'Thank you!
|
| 59 |
options = [
|
| 60 |
-
{ text: '
|
| 61 |
-
{ text: '
|
| 62 |
];
|
| 63 |
}
|
| 64 |
|
|
@@ -157,9 +157,9 @@ function getFoodSuggestions() {
|
|
| 157 |
.then(response => response.json())
|
| 158 |
.then(data => {
|
| 159 |
if (data.error) {
|
| 160 |
-
addMessage('bot', `Sorry, there was an error getting
|
| 161 |
} else {
|
| 162 |
-
addMessage('bot', 'Here are some
|
| 163 |
data.suggestions.forEach(suggestion => addMessage('bot', suggestion));
|
| 164 |
addMessage('bot', 'Would you like to start over or select more ingredients?');
|
| 165 |
displayOptions([
|
|
@@ -169,7 +169,7 @@ function getFoodSuggestions() {
|
|
| 169 |
}
|
| 170 |
})
|
| 171 |
.catch(error => {
|
| 172 |
-
addMessage('bot', `Error: Unable to get
|
| 173 |
});
|
| 174 |
}
|
| 175 |
|
|
|
|
| 52 |
botResponse = 'Great choice! 🍽️ Fetching non-vegetarian ingredients...';
|
| 53 |
fetchIngredients('non-vegetarian');
|
| 54 |
} else if (selectedIngredients.length > 0 && lastMessage === 'suggest') {
|
| 55 |
+
botResponse = 'Generating recipe ideas based on your selected ingredients...';
|
| 56 |
getFoodSuggestions();
|
| 57 |
} else if (lastMessage === 'done') {
|
| 58 |
+
botResponse = 'Thank you! Please type "suggest" to get recipe ideas based on your selected ingredients, or "start over" to begin again.';
|
| 59 |
options = [
|
| 60 |
+
{ text: 'Suggest', class: '' },
|
| 61 |
+
{ text: 'Start Over', class: '' }
|
| 62 |
];
|
| 63 |
}
|
| 64 |
|
|
|
|
| 157 |
.then(response => response.json())
|
| 158 |
.then(data => {
|
| 159 |
if (data.error) {
|
| 160 |
+
addMessage('bot', `Sorry, there was an error getting recipe ideas: ${data.error}`);
|
| 161 |
} else {
|
| 162 |
+
addMessage('bot', 'Here are some recipe ideas based on your selected ingredients:');
|
| 163 |
data.suggestions.forEach(suggestion => addMessage('bot', suggestion));
|
| 164 |
addMessage('bot', 'Would you like to start over or select more ingredients?');
|
| 165 |
displayOptions([
|
|
|
|
| 169 |
}
|
| 170 |
})
|
| 171 |
.catch(error => {
|
| 172 |
+
addMessage('bot', `Error: Unable to get recipe ideas. ${error.message}`);
|
| 173 |
});
|
| 174 |
}
|
| 175 |
|