Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +4 -4
static/script.js
CHANGED
|
@@ -20,7 +20,7 @@ function addMessage(role, message) {
|
|
| 20 |
}
|
| 21 |
|
| 22 |
function sendMessage() {
|
| 23 |
-
const userInput = document.getElementById('
|
| 24 |
if (!userInput) {
|
| 25 |
console.error('User input field not found!');
|
| 26 |
return;
|
|
@@ -111,9 +111,9 @@ function fetchIngredients(foodPreference) {
|
|
| 111 |
.then(data => {
|
| 112 |
console.log('Response data:', data);
|
| 113 |
if (data.error) {
|
| 114 |
-
addMessage('bot', `
|
| 115 |
} else if (!data.ingredients || data.ingredients.length === 0) {
|
| 116 |
-
addMessage('bot', 'No ingredients found for this selection. Please try another option.');
|
| 117 |
} else {
|
| 118 |
const ingredients = data.ingredients;
|
| 119 |
addMessage('bot', 'Please select ingredients:');
|
|
@@ -123,7 +123,7 @@ function fetchIngredients(foodPreference) {
|
|
| 123 |
})
|
| 124 |
.catch(error => {
|
| 125 |
console.error('Fetch error:', error);
|
| 126 |
-
addMessage('bot', `
|
| 127 |
});
|
| 128 |
}
|
| 129 |
|
|
|
|
| 20 |
}
|
| 21 |
|
| 22 |
function sendMessage() {
|
| 23 |
+
const userInput = document.getElementById('chatMessages');
|
| 24 |
if (!userInput) {
|
| 25 |
console.error('User input field not found!');
|
| 26 |
return;
|
|
|
|
| 111 |
.then(data => {
|
| 112 |
console.log('Response data:', data);
|
| 113 |
if (data.error) {
|
| 114 |
+
addMessage('bot', `Error fetching ingredients: ${data.error}`);
|
| 115 |
} else if (!data.ingredients || data.ingredients.length === 0) {
|
| 116 |
+
addMessage('bot', 'No ingredients found for this selection. Please try another option or check backend data.');
|
| 117 |
} else {
|
| 118 |
const ingredients = data.ingredients;
|
| 119 |
addMessage('bot', 'Please select ingredients:');
|
|
|
|
| 123 |
})
|
| 124 |
.catch(error => {
|
| 125 |
console.error('Fetch error:', error);
|
| 126 |
+
addMessage('bot', `Failed to load ingredients: ${error.message}. Check console for details.`);
|
| 127 |
});
|
| 128 |
}
|
| 129 |
|