code: def get_response(
      self,
      outputs,
      prompt=None,
      sanitize_bot_response=False,
      only_new_text=False,
      plain_prompt_special=False,
  ):
      if isinstance(outputs, str):
          outputs = [outputs]
      if self.debug:
          print("output:\n%s" % "\n\n".join(outputs), flush=True)
      if prompt is not None:
          self.prompt = prompt
  
      def clean_response(response):
          meaningless_words = ["<pad>", "</s>", "<|endoftext|>"]
          for word in meaningless_words:
              response = response.replace(word, "")
          if sanitize_bot_response:
              # from better_profanity import profanity
              # response = profanity.censor(response)
              pass
          if (
              self.generates_leading_space
              and isinstance(response, str)
              and len(response) > 0
              and response[0] == " "
          ):
              response = response[1:]
          return response
  
      def clean_repeats(response):
          lines = response.split("\n")
          new_lines = []
          [
              new_lines.append(line)
              for line in lines
              if line not in new_lines
              or len(line) < self.allowed_repeat_line_length
          ]
          if self.debug and len(lines) != len(new_lines):
              print(
                  "cleaned repeats: %s %s"
                  % (len(lines), len(new_lines)),
                  flush=True,
              )
          response = "\n".join(new_lines)
          return response
  
      multi_output = len(outputs) > 1
  
      for oi, output in enumerate(outputs):
          if plain_prompt_special and self.prompt_type in [
              PromptType.plain.value,
              str(PromptType.plain.value),
              PromptType.plain.name,
          ]:
              output = clean_response(output)
              allow_terminate = True
          elif only_new_text:
              # only use terminate, that will have other variations of cleaning that include \n etc. not just simple human bot that will leave residual \n
              allow_terminate = True
          elif prompt is None:
              allow_terminate = True
              # then use most basic parsing like pipeline
              if not self.botstr:
                  pass
              else:
                  if self.humanstr:
                      output = clean_response(
                          output.split(self.botstr)[-1].split(
                              self.humanstr
                          )[0]
                      )
                  else:
                      # i.e. use after bot but only up to next bot
                      output = clean_response(
                          output.split(self.botstr)[-1].split(
                              self.botstr
                          )[0]
                      )
          else:
              # find first instance of prereponse
              # prompt sometimes has odd characters, that mutate length,
              # so can't go by length alone
              if self.pre_response:
                  outputi = output.find(prompt)
                  if outputi >= 0:
                      output = output[outputi + len(prompt) :]
                      allow_terminate = True
                  else:
                      # subtraction is risky due to space offsets sometimes, so only do if necessary
                      output = output[
                          len(prompt) - len(self.pre_response) :
                      ]
                      # [1] to avoid repeated pre_response, just take first (after prompt - pre_response for chat)
                      if self.pre_response in output:
                          output = output.split(self.pre_response)[1]
                          allow_terminate = True
                      else:
                          if output:
                              print(
                                  "Failure of parsing or not enough output yet: %s"
                                  % output,
                                  flush=True,
                              )
                          allow_terminate = False
              else:
                  allow_terminate = True
                  output = output[len(prompt) :]
              # clean after subtract prompt out, so correct removal of pre_response
              output = clean_response(output)
          if self.repeat_penalty:
              output = clean_repeats(output)
          if self.terminate_response and allow_terminate:
              finds = []
              for term in self.terminate_response:
                  finds.append(output.find(term))
              finds = [x for x in finds if x >= 0]
              if len(finds) > 0:
                  termi = finds[0]
                  output = output[:termi]
              else:
                  output = output
          if multi_output:
              # prefix with output counter
              output = "\n=========== Output %d\n\n" % (1 + oi) + output
              if oi > 0:
                  # post fix outputs with seperator
                  output += "\n"
          output = self.fix_text(self.prompt_type, output)
          outputs[oi] = output
      # join all outputs, only one extra new line between outputs
      output = "\n".join(outputs)
      if self.debug:
          print("outputclean:\n%s" % "\n\n".join(outputs), flush=True)
      return output
  
file_path: h2ogpt/src/prompter.py
imports: import ast
  import time
  from enums import PromptType, gpt_token_mapping, anthropic_mapping, google_mapping, mistralai_mapping
label_desc: Use image node_id 4 for calling the Prompter obj's underlying member method code with example usage: obj.get_response(outputs, prompt, sanitize_bot_response, only_new_text, plain_prompt_special) and returns: output, response, response