From c70685682d63a1fddc91ddd030b6387935a4dc84 Mon Sep 17 00:00:00 2001 From: Krzysztof Bojakowski Date: Fri, 3 May 2024 00:30:43 +0200 Subject: [PATCH] Poprawki do dependency, dodanie przykladu do main.py --- src/main.py | 18 ++++++++++++------ src/model/frame.py | 5 +++-- src/service/dialog_policy.py | 5 ++--- src/service/dialog_state_monitor.py | 2 +- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main.py b/src/main.py index 95396a5..5c20fb1 100644 --- a/src/main.py +++ b/src/main.py @@ -1,10 +1,16 @@ -from src.model.frame import Frame -from src.service.dialog_state_monitor import DialogStateMonitor +from model.frame import Frame +from service.dialog_state_monitor import DialogStateMonitor +from service.dialog_policy import DialogPolicy # Example +print("Dialog state monitor, examples:") monitor = DialogStateMonitor() -monitor.append(Frame('system', 'hello')) -monitor.append(Frame('user', 'some text')) -print(monitor.get_all()[0].text) -print(monitor.get_last().text) +monitor.append(Frame('system', 'hello', [])) +monitor.append(Frame('user', 'some_text', [])) +print(monitor.get_all()[0].act) +print(monitor.get_last().act) + +print("Dialog policy, next dialogue act:") +dialog_policy = DialogPolicy(monitor.get_all()) +print(dialog_policy.next_dialogue_act().act) diff --git a/src/model/frame.py b/src/model/frame.py index 66fad20..a4ae6d5 100644 --- a/src/model/frame.py +++ b/src/model/frame.py @@ -1,6 +1,7 @@ -from slot import Slot +from model.slot import Slot class Frame: - def __init__(self, act: str, slots: list[Slot]): + def __init__(self, source: str, act: str, slots: list[Slot]): + self.source = source self.slots = slots self.act = act diff --git a/src/service/dialog_policy.py b/src/service/dialog_policy.py index a3cf40f..28fe96e 100644 --- a/src/service/dialog_policy.py +++ b/src/service/dialog_policy.py @@ -1,5 +1,4 @@ from model.frame import Frame -from model.dialogue_act import DialogueAct class DialogPolicy: def __init__(self, frames: list[Frame]) -> None: @@ -7,6 +6,6 @@ class DialogPolicy: def next_dialogue_act(self) -> Frame: if self.frames[-1].act == "welcomemsg": - return Frame("welcomemsg", []) + return Frame("system", "welcomemsg", []) else: - return Frame("canthelp", []) + return Frame("system", "canthelp", []) diff --git a/src/service/dialog_state_monitor.py b/src/service/dialog_state_monitor.py index 9bfad0f..0c62631 100644 --- a/src/service/dialog_state_monitor.py +++ b/src/service/dialog_state_monitor.py @@ -1,4 +1,4 @@ -from src.model.frame import Frame +from model.frame import Frame class DialogStateMonitor: