From 82f1c9b0da04c46913850fd2a32e68722d04495a Mon Sep 17 00:00:00 2001 From: Patryk Date: Fri, 19 Apr 2024 21:22:02 +0200 Subject: [PATCH] =?UTF-8?q?Dodani=20makiety=20dla=20monitora=20stanu=20dia?= =?UTF-8?q?logu=20i=20ramki=20wraz=20z=20przyk=C5=82adami=20u=C5=BCycia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.py | 10 ++++++++++ src/model/frame.py | 4 ++++ src/service/dialog_state_monitor.py | 14 ++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 src/main.py create mode 100644 src/model/frame.py create mode 100644 src/service/dialog_state_monitor.py diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..95396a5 --- /dev/null +++ b/src/main.py @@ -0,0 +1,10 @@ +from src.model.frame import Frame +from src.service.dialog_state_monitor import DialogStateMonitor + + +# Example +monitor = DialogStateMonitor() +monitor.append(Frame('system', 'hello')) +monitor.append(Frame('user', 'some text')) +print(monitor.get_all()[0].text) +print(monitor.get_last().text) diff --git a/src/model/frame.py b/src/model/frame.py new file mode 100644 index 0000000..bdbc717 --- /dev/null +++ b/src/model/frame.py @@ -0,0 +1,4 @@ +class Frame: + def __init__(self, source: str, text: str): + self.source = source + self.text = text diff --git a/src/service/dialog_state_monitor.py b/src/service/dialog_state_monitor.py new file mode 100644 index 0000000..9bfad0f --- /dev/null +++ b/src/service/dialog_state_monitor.py @@ -0,0 +1,14 @@ +from src.model.frame import Frame + + +class DialogStateMonitor: + dialog = [] + + def append(self, frame: Frame): + self.dialog.append(frame) + + def get_all(self) -> [Frame]: + return self.dialog + + def get_last(self) -> Frame: + return self.dialog[len(self.dialog) - 1]