Dopytujemy o kompletne zamówienie

This commit is contained in:
s495727 2024-06-13 16:36:17 +02:00
parent 02312cc3b9
commit 75fb0f873b
3 changed files with 23 additions and 7 deletions

View File

@ -24,10 +24,13 @@ class DialogPolicy:
return Frame(source="system", act = "bye_and_thanks")
match(current_active_stage['name']):
case "collect_food":
# current_active_stage['confirmed'] = True
return Frame(source="system", act = "request/food", slots = [Slot("menu", dsm.state['constants']['menu'])], act_understood=act_processed)
case "collect_drinks":
return Frame(source="system", act = "request/drinks", slots = [Slot("drink", dsm.state['constants']['drink'])], act_understood=act_processed)
case "more_food":
return Frame(source="system", act = "request/food-more", slots = [Slot("menu", dsm.state['constants']['menu'])], act_understood=act_processed)
case "more_drinks":
return Frame(source="system", act = "request/drinks-more", slots = [Slot("drink", dsm.state['constants']['drink'])], act_understood=act_processed)
case "collect_address":
return Frame(source="system", act = "request/address", act_understood=act_processed)
case "collect_payment_method":

View File

@ -37,7 +37,8 @@ def generate_ingredients_response(slots):
return "Nie podano składników."
def generate_drinks_response(slots):
def generate_drinks_response(slots, act):
more = 'drinks-more' in act
drinks = [slot['value'] for slot in slots if slot['name'] == 'drink']
if drinks:
drink_details = []
@ -45,11 +46,18 @@ def generate_drinks_response(slots):
for name, details in drink.items():
# price = details.get('price', 'unknown')
drink_details.append(f"{name}") # w cenie {price} zł")
if not more:
if len(drink_details) > 1:
response = f"Czy chcesz coś do picia? Dostępne napoje to: {', '.join(drink_details[:-1])} oraz {drink_details[-1]}."
else:
response = f"Czy chcesz coś do picia? Dostępne napoje to: {drink_details[0]}."
return response
else:
if len(drink_details) > 1:
response = f"Czy chcesz coś jeszcze picia? Dostępne napoje to: {', '.join(drink_details[:-1])} oraz {drink_details[-1]}."
else:
response = f"Czy chcesz coś jeszcze picia? Dostępne napoje to: {drink_details[0]}."
return response
return "Nie podano napojów."
def generate_size_response(slots):
@ -80,7 +88,7 @@ def select_template(act, slots):
if "ingredients" in slot_names:
return generate_ingredients_response(slots)
elif "drink" in slot_names:
return generate_drinks_response(slots)
return generate_drinks_response(slots, act)
elif "sauce" in slot_names:
return generate_sauce_response(slots)
elif "size" in slot_names:
@ -154,6 +162,8 @@ def select_template(act, slots):
return random.choice(templates["request/drinks"])
elif act == "request/food":
return random.choice(templates["inform/menu"])
elif act == "request/food-more":
return random.choice(templates["inform/menu-more"])
elif act == "inform/name":
return random.choice(templates["inform/name"])
elif act == "bye":

View File

@ -9,6 +9,9 @@ templates = {
"inform/menu": [
"Oferujemy następujące pizze: {menu}.",
],
"inform/menu-more": [
"Czy chcesz jeszcze jakąś pizzę? Dla przypomnienia w menu mamy {menu}.",
],
"inform/name": [
"Twoje imię to {name}.",
"Podane imię: {name}.",