Dopytujemy o kompletne zamówienie
This commit is contained in:
parent
02312cc3b9
commit
75fb0f873b
@ -24,10 +24,13 @@ class DialogPolicy:
|
|||||||
return Frame(source="system", act = "bye_and_thanks")
|
return Frame(source="system", act = "bye_and_thanks")
|
||||||
match(current_active_stage['name']):
|
match(current_active_stage['name']):
|
||||||
case "collect_food":
|
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)
|
return Frame(source="system", act = "request/food", slots = [Slot("menu", dsm.state['constants']['menu'])], act_understood=act_processed)
|
||||||
case "collect_drinks":
|
case "collect_drinks":
|
||||||
return Frame(source="system", act = "request/drinks", slots = [Slot("drink", dsm.state['constants']['drink'])], act_understood=act_processed)
|
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":
|
case "collect_address":
|
||||||
return Frame(source="system", act = "request/address", act_understood=act_processed)
|
return Frame(source="system", act = "request/address", act_understood=act_processed)
|
||||||
case "collect_payment_method":
|
case "collect_payment_method":
|
||||||
|
@ -37,7 +37,8 @@ def generate_ingredients_response(slots):
|
|||||||
return "Nie podano składników."
|
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']
|
drinks = [slot['value'] for slot in slots if slot['name'] == 'drink']
|
||||||
if drinks:
|
if drinks:
|
||||||
drink_details = []
|
drink_details = []
|
||||||
@ -45,11 +46,18 @@ def generate_drinks_response(slots):
|
|||||||
for name, details in drink.items():
|
for name, details in drink.items():
|
||||||
# price = details.get('price', 'unknown')
|
# price = details.get('price', 'unknown')
|
||||||
drink_details.append(f"{name}") # w cenie {price} zł")
|
drink_details.append(f"{name}") # w cenie {price} zł")
|
||||||
|
if not more:
|
||||||
if len(drink_details) > 1:
|
if len(drink_details) > 1:
|
||||||
response = f"Czy chcesz coś do picia? Dostępne napoje to: {', '.join(drink_details[:-1])} oraz {drink_details[-1]}."
|
response = f"Czy chcesz coś do picia? Dostępne napoje to: {', '.join(drink_details[:-1])} oraz {drink_details[-1]}."
|
||||||
else:
|
else:
|
||||||
response = f"Czy chcesz coś do picia? Dostępne napoje to: {drink_details[0]}."
|
response = f"Czy chcesz coś do picia? Dostępne napoje to: {drink_details[0]}."
|
||||||
return response
|
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."
|
return "Nie podano napojów."
|
||||||
|
|
||||||
def generate_size_response(slots):
|
def generate_size_response(slots):
|
||||||
@ -80,7 +88,7 @@ def select_template(act, slots):
|
|||||||
if "ingredients" in slot_names:
|
if "ingredients" in slot_names:
|
||||||
return generate_ingredients_response(slots)
|
return generate_ingredients_response(slots)
|
||||||
elif "drink" in slot_names:
|
elif "drink" in slot_names:
|
||||||
return generate_drinks_response(slots)
|
return generate_drinks_response(slots, act)
|
||||||
elif "sauce" in slot_names:
|
elif "sauce" in slot_names:
|
||||||
return generate_sauce_response(slots)
|
return generate_sauce_response(slots)
|
||||||
elif "size" in slot_names:
|
elif "size" in slot_names:
|
||||||
@ -154,6 +162,8 @@ def select_template(act, slots):
|
|||||||
return random.choice(templates["request/drinks"])
|
return random.choice(templates["request/drinks"])
|
||||||
elif act == "request/food":
|
elif act == "request/food":
|
||||||
return random.choice(templates["inform/menu"])
|
return random.choice(templates["inform/menu"])
|
||||||
|
elif act == "request/food-more":
|
||||||
|
return random.choice(templates["inform/menu-more"])
|
||||||
elif act == "inform/name":
|
elif act == "inform/name":
|
||||||
return random.choice(templates["inform/name"])
|
return random.choice(templates["inform/name"])
|
||||||
elif act == "bye":
|
elif act == "bye":
|
||||||
|
@ -9,6 +9,9 @@ templates = {
|
|||||||
"inform/menu": [
|
"inform/menu": [
|
||||||
"Oferujemy następujące pizze: {menu}.",
|
"Oferujemy następujące pizze: {menu}.",
|
||||||
],
|
],
|
||||||
|
"inform/menu-more": [
|
||||||
|
"Czy chcesz jeszcze jakąś pizzę? Dla przypomnienia w menu mamy {menu}.",
|
||||||
|
],
|
||||||
"inform/name": [
|
"inform/name": [
|
||||||
"Twoje imię to {name}.",
|
"Twoje imię to {name}.",
|
||||||
"Podane imię: {name}.",
|
"Podane imię: {name}.",
|
||||||
|
Loading…
Reference in New Issue
Block a user