2024-06-11 18:10:51 +02:00
|
|
|
from modules.nlu import Act, Slot
|
|
|
|
import random
|
2024-05-07 21:40:14 +02:00
|
|
|
|
|
|
|
|
2024-06-11 01:56:44 +02:00
|
|
|
class DialoguePolicy:
|
|
|
|
|
2024-06-11 18:10:51 +02:00
|
|
|
def next_action(self, dst):
|
|
|
|
if not dst.state['belief_state']['order-complete']:
|
|
|
|
user_intent = dst.state['act']
|
2024-06-11 01:56:44 +02:00
|
|
|
if user_intent == "inform":
|
|
|
|
empty_slot = dst.find_first_empty_slot()
|
2024-06-11 18:10:51 +02:00
|
|
|
return Act(intent="request", slots=[Slot(name=empty_slot, value='')])
|
|
|
|
elif user_intent == "request":
|
|
|
|
if dst.state['slot_names']:
|
|
|
|
slot = random.choice(dst.state['slot_names'])
|
|
|
|
return Act(intent="inform", slots=[Slot(name=slot, value='')])
|
2024-06-11 01:56:44 +02:00
|
|
|
else:
|
2024-06-11 18:10:51 +02:00
|
|
|
return Act(intent="canthelp", slots=[Slot(name='unknown', value='')])
|
|
|
|
elif user_intent == "bye":
|
|
|
|
return Act(intent="bye", slots=[Slot(name='', value='')])
|
|
|
|
else:
|
|
|
|
return Act(intent="canthelp", slots=[Slot(name='unknown', value='')])
|
2024-06-11 01:56:44 +02:00
|
|
|
else:
|
2024-06-11 18:10:51 +02:00
|
|
|
return Act(intent="inform", slots=[Slot(name='confirmation', value='Zamówienie złożono poprawnie.')])
|