sklep-internetowy-systemy-d.../chatbot/main.py
2024-05-07 23:14:14 +02:00

36 lines
988 B
Python

from pathlib import Path
from modules.nlp import NaturalLanguageProcessor
from modules.generator import ResponseGenerator
from modules.config import Config
import colorama
from colorama import Fore, Style
colorama.init(autoreset=True)
def main():
base_path = Path(__file__).resolve().parent
config_path = base_path / 'config' / 'config.json'
config = Config.load_config(config_path)
nlp = NaturalLanguageProcessor(config)
generator = ResponseGenerator(config)
print(Fore.CYAN + "Witaj w chatbocie! Rozpocznij rozmowę.")
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
intent = nlp.analyze(user_input)
response = generator.generate(intent)
print(Fore.CYAN + "Bot: " + response)
if __name__ == "__main__":
main()