2024-05-07 21:40:14 +02:00
|
|
|
from pathlib import Path
|
2024-06-11 00:51:22 +02:00
|
|
|
from modules.nlu import NLU, Slot, UserAct
|
|
|
|
from modules.state_monitor import DialogStateMonitor
|
2024-05-07 21:40:14 +02:00
|
|
|
from modules.generator import ResponseGenerator
|
|
|
|
from modules.config import Config
|
2024-05-05 21:42:45 +02:00
|
|
|
import colorama
|
|
|
|
from colorama import Fore, Style
|
|
|
|
|
|
|
|
colorama.init(autoreset=True)
|
|
|
|
|
|
|
|
|
2024-05-07 21:40:14 +02:00
|
|
|
def main():
|
|
|
|
base_path = Path(__file__).resolve().parent
|
|
|
|
config_path = base_path / 'config' / 'config.json'
|
|
|
|
config = Config.load_config(config_path)
|
2024-05-05 21:42:45 +02:00
|
|
|
|
2024-06-11 00:51:22 +02:00
|
|
|
nlu = NLU()
|
|
|
|
dst = DialogStateMonitor()
|
2024-05-07 21:40:14 +02:00
|
|
|
generator = ResponseGenerator(config)
|
|
|
|
|
|
|
|
print(Fore.CYAN + "Witaj w chatbocie! Rozpocznij rozmowę.")
|
2024-05-05 21:42:45 +02:00
|
|
|
print(Fore.YELLOW + "Wpisz 'quit' aby zakończyć program.\n")
|
|
|
|
|
|
|
|
while True:
|
|
|
|
user_input = input(Fore.GREEN + "Ty: " + Style.RESET_ALL)
|
|
|
|
if user_input.lower() == "quit":
|
|
|
|
print(Fore.RED + "Zamykanie chatbota...")
|
|
|
|
break
|
|
|
|
|
2024-06-11 00:51:22 +02:00
|
|
|
user_act = nlu.analyze(user_input)
|
|
|
|
# user_act = UserAct(intent='inform',
|
|
|
|
# slots=[Slot(name='item', value='laptop'), Slot(name='item', value='kot'),Slot(name='address', value='123 Main St')])
|
|
|
|
dst.update(user_act)
|
|
|
|
print(dst.state)
|
|
|
|
# response = generator.generate(intent)
|
2024-05-07 23:14:14 +02:00
|
|
|
|
2024-06-11 00:51:22 +02:00
|
|
|
# print(Fore.CYAN + "Bot: " + response)
|
2024-05-07 21:40:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|