add mock model

This commit is contained in:
Karol Cyganik 2024-04-16 12:28:58 +02:00
parent f867485ec3
commit 5641552a38

69
dialog_model.py Normal file
View File

@ -0,0 +1,69 @@
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)