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