<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _generate_keys(self):
        '''the discourse API requires the interactions to be signed, so we 
           generate a keypair on behalf of the user
        '''
        from helpme.defaults import HELPME_CLIENT_SECRETS
        keypair_dir = os.path.join(os.path.dirname(HELPME_CLIENT_SECRETS),
                                   'discourse')

        # Have we generated a keypair file before?
        self.keypair_file = os.path.join(keypair_dir, 'private.pem')

        # We likely won't have generated it on first use!
        if not hasattr(self, 'key'):
            self.key = generate_keypair(self.keypair_file)           

        # If we generated the keypair file, we will have already loaded the key
        if not hasattr(self, 'public_key'):
            self.public_key = load_keypair(self.keypair_file)