CoolFace
Apppublic

DevMastersZA/Marco_Professional_Profile

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
controller.py21 linesDownload Raw Back to chatbot_rag_evaluation
1from chat import Chat2from rag import Retriever3from evaluator import Evaluator4 5class ChatbotController:6    def __init__(self):7        self.retriever = Retriever()8        self.chatbot = Chat()9        self.evaluator = Evaluator(name="Damla")10 11    def get_response(self, message, history, recorded_emails):12        chunks = self.retriever.get_relevant_chunks(message)13        reply, new_recorded_emails = self.chatbot.chat(message, history, recorded_emails, chunks)14        evaluation = self.evaluator.evaluate(reply, message, history)15 16        while not evaluation.is_acceptable:17            print("Retrying due to failed evaluation...")18            reply = self.chatbot.rerun(reply, message, history, evaluation.feedback)19            evaluation = self.evaluator.evaluate(reply, message, history)20 21        return reply, new_recorded_emails