From 896f93f8f050b50923a39f29d28f2f9bb20b457a Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Fri, 10 May 2024 19:34:50 +0700 Subject: [PATCH] Create chatbot.py --- customer_service/chatbot.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 customer_service/chatbot.py diff --git a/customer_service/chatbot.py b/customer_service/chatbot.py new file mode 100644 index 000000000..8ff98a9a1 --- /dev/null +++ b/customer_service/chatbot.py @@ -0,0 +1,14 @@ +import time + +class Chatbot: + def __init__(self, nlp_model, knowledge_base): + self.nlp_model = nlp_model + self.knowledge_base = knowledge_base + + def chat(self, user_input): + entities = self.nlp_model.extract_entities(user_input) + intent = self.nlp_model.extract_intent(user_input) + response = self.knowledge_base.get_response(intent) + print('User:', user_input) + print('Chatbot:', response) + time.sleep(1)