Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +6 -22
static/script.js
CHANGED
|
@@ -42,7 +42,7 @@ function handleResponse(userInput) {
|
|
| 42 |
let botResponse = '';
|
| 43 |
|
| 44 |
if (conversation.length === 2) {
|
| 45 |
-
botResponse = `Great to meet you, ${userInput}! 🍳 What kind of food are you craving today?
|
| 46 |
displayOptions([
|
| 47 |
{ text: 'Vegetarian', class: 'green' },
|
| 48 |
{ text: 'Non-Vegetarian', class: 'red' },
|
|
@@ -54,25 +54,9 @@ function handleResponse(userInput) {
|
|
| 54 |
addMessage('bot', botResponse);
|
| 55 |
fetchMenuItems(lowerInput);
|
| 56 |
} else {
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
body: JSON.stringify({ message: userInput, session_id: 'default' })
|
| 61 |
-
})
|
| 62 |
-
.then(response => response.json())
|
| 63 |
-
.then(data => {
|
| 64 |
-
if (data.error) {
|
| 65 |
-
addMessage('bot', `Oops! ${data.error}. Let’s try something else!`);
|
| 66 |
-
} else {
|
| 67 |
-
addMessage('bot', data.response);
|
| 68 |
-
// Check if the input might be a menu item or ingredient
|
| 69 |
-
fetchMenuItems(null, userInput);
|
| 70 |
-
}
|
| 71 |
-
})
|
| 72 |
-
.catch(error => {
|
| 73 |
-
addMessage('bot', `Yikes! Couldn’t reach the assistant: ${error.message}. Try searching for 'chicken' or 'paneer'!`);
|
| 74 |
-
fetchMenuItems(null, userInput);
|
| 75 |
-
});
|
| 76 |
}
|
| 77 |
}
|
| 78 |
|
|
@@ -358,7 +342,7 @@ function showDescriptionPopup(item) {
|
|
| 358 |
selectedItem.dynamic_dish = item.dynamic_dish;
|
| 359 |
}
|
| 360 |
if (selectedItems.some(existing => existing.name === selectedItem.name)) {
|
| 361 |
-
addMessage('
|
| 362 |
} else {
|
| 363 |
selectedItems.push(selectedItem);
|
| 364 |
addMessage('bot', `Added "${selectedItem.name}" to your selection! Check the box below.`);
|
|
@@ -562,7 +546,7 @@ function resetConversation() {
|
|
| 562 |
conversation = [
|
| 563 |
{ role: 'bot', message: `Hello! I’m Chef Bot, your culinary assistant! What’s your name?` },
|
| 564 |
{ role: 'user', message: userName },
|
| 565 |
-
{ role: 'bot', message: `Great to meet you, ${userName}! 🍳 What kind of food are you craving today?
|
| 566 |
];
|
| 567 |
selectedItems = [];
|
| 568 |
selectionBoxVisible = true;
|
|
|
|
| 42 |
let botResponse = '';
|
| 43 |
|
| 44 |
if (conversation.length === 2) {
|
| 45 |
+
botResponse = `Great to meet you, ${userInput}! 🍳 What kind of food are you craving today? Try searching for 'chicken' or select a preference below!`;
|
| 46 |
displayOptions([
|
| 47 |
{ text: 'Vegetarian', class: 'green' },
|
| 48 |
{ text: 'Non-Vegetarian', class: 'red' },
|
|
|
|
| 54 |
addMessage('bot', botResponse);
|
| 55 |
fetchMenuItems(lowerInput);
|
| 56 |
} else {
|
| 57 |
+
botResponse = `Searching for "${userInput}" in our menu...`;
|
| 58 |
+
addMessage('bot', botResponse);
|
| 59 |
+
fetchMenuItems(null, userInput);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
}
|
| 61 |
}
|
| 62 |
|
|
|
|
| 342 |
selectedItem.dynamic_dish = item.dynamic_dish;
|
| 343 |
}
|
| 344 |
if (selectedItems.some(existing => existing.name === selectedItem.name)) {
|
| 345 |
+
addMessage('-known', `"${selectedItem.name}" is already in your selection!`);
|
| 346 |
} else {
|
| 347 |
selectedItems.push(selectedItem);
|
| 348 |
addMessage('bot', `Added "${selectedItem.name}" to your selection! Check the box below.`);
|
|
|
|
| 546 |
conversation = [
|
| 547 |
{ role: 'bot', message: `Hello! I’m Chef Bot, your culinary assistant! What’s your name?` },
|
| 548 |
{ role: 'user', message: userName },
|
| 549 |
+
{ role: 'bot', message: `Great to meet you, ${userName}! 🍳 What kind of food are you craving today? Try searching for 'chicken' or select a preference below!` }
|
| 550 |
];
|
| 551 |
selectedItems = [];
|
| 552 |
selectionBoxVisible = true;
|