Update src/main.py

This commit is contained in:
s495724 2024-06-12 16:02:39 +02:00
parent e7a8814438
commit 41f41cc692

View File

@ -10,6 +10,12 @@ monitor = DialogStateMonitor() # DSM
dialog_policy = DialogPolicy() # DP
language_generation = NaturalLanguageGeneration(templates) # NLG
def frame_to_dict(frame):
return {
"act": frame.act,
"slots": [{"name": slot.name, "value": slot.value} for slot in frame.slots]
}
# Main loop
dial_num = 0
@ -17,8 +23,8 @@ print("CTRL+C aby zakończyć program.")
while True:
monitor.reset()
print(f"\n==== Rozpoczynasz rozmowę nr {dial_num} ====\n")
user_input = input("Możesz zacząć pisać.\n")
# print(f"\n==== Rozpoczynasz rozmowę nr {dial_num} ====\n")
user_input = input("Witamy w naszej pizzerii. W czym mogę pomóc?\n")
while True:
# NLU
@ -30,14 +36,15 @@ while True:
# DP
system_action = dialog_policy.predict(monitor)
system_action = frame_to_dict(system_action) # Ensure system_action is a dictionary
print("System action: ", system_action)
# NLG
act, slots = parse_frame(frame)
response = language_generation.generate(act, slots)
response = language_generation.generate(frame, system_action)
print(response)
if frame.act == "bye":
break
user_input = input(">\n")
# dial_num += 1