JARVIS/dialog_model.py
2024-04-16 12:28:58 +02:00

70 lines
1.2 KiB
Python

from typing import Any
class Model():
def __init__(self):
pass
def __call__(self, prompt) -> Any:
nlu = NLU()
dst = DST()
dp = DP()
nlg = NLG()
msg = prompt
rama_nlu = nlu(msg)
rama_dst = dst(rama_nlu)
rama_dp = dp(rama_dst)
text = nlg(rama_dp)
return text
class NLU():
def __init__(self):
pass
def __call__(self, prompt) -> Any:
msg = prompt
if "imie" in msg:
return "jakie imie"
class DST():
def __init__(self):
self.msgs = []
def __call__(self, msg) -> Any:
self.msgs.append(msg)
return msg
class DP():
def __init__(self):
pass
def __call__(self, msg) -> Any:
if "imie" in msg:
return "imieMSG"
else:
return None
class NLG():
def __init__(self):
pass
def __call__(self, msg) -> Any:
if msg == "imieMSG":
return "Mam na imie JARVIS"
else:
return "Nie rozumiem"
if __name__ == "__main__":
model = Model()
ans = model(prompt="Jak masz na imie")
print(ans)