



class Chatbot():
    """
    Super class for Chatbot. Chatbot is a language model used to generate text, 
    including internal dialogue and replies to the user.

    Meant to be overriden by API calling class or class that uses local model.
    """
    def __init__(self,autogram_config):
        self.do_post_process = autogram_config.post_process_response
        self.test_mode=False
        self.test_reply="<Test mode enabled, no response given>"



    def set_test_mode(self,test_mode):
        self.test_mode=test_mode


    def __call__(self, inputs,outputs,prefix=None):
        if self.test_mode:
            #when in test mode, give a fixed reply
            response = [self.test_reply]
            success=True
            return response,success
        else:
            #otherwise call subclass to generate reply
            return self.generate_reply(inputs,outputs,prefix=prefix)
        
    
    def generate_reply(self,inputs,outputs,prefix=None):
        """
        args:
            inputs - a list of past inputs given to model, as well as the current input. Includes combination of instructions and user replies
            outputs - a list of past outputs generated by the model as previous turns. len(outputs) should be 1 shorter than inputs.
            prefix - start of reply. Can only be used by local models and completion apis, otherwise unused
        returns:
            responses - list of responses generated by model
            success - whether model gave result without errors (or generating text that doesn't meet requirements)
        """
        raise NotImplementedError("generated_reply() needs to be implemented by subclass chatbot")
    def truncate_input(self,inputs,outputs,prefix=None):
        """
        args:
            inputs - a list of past inputs given to model, as well as the current input. Includes combination of instructions and user replies
            outputs - a list of past outputs generated by the model as previous turns. len(outputs) should be 1 shorter than inputs.
            prefix - start of reply. Can only be used by local models and completion apis, otherwise unused
        returns:
            new_inputs - original list truncated to meet contraints on prompt length
            new_outputs - original list truncated to meet contrainst on prompt length
            new_prefix -  will usually remain unchanged

        """

        raise NotImplementedError("truncate_input() needs to be implemented by subclass chatbot")