docstr: HF-like pipeline, but handle instruction prompting and stopping (for some models)
  :param args:
  :param debug:
  :param chat:
  :param stream_output:
  :param sanitize_bot_response:
  :param use_prompter: Whether to use prompter.  If pass prompt_type, will make prompter
  :param prompter: prompter, can pass if have already
  :param prompt_type: prompt_type, e.g. human_bot.  See prompt_type to model mapping in from prompter.py.
                      If use_prompter, then will make prompter and use it.
  :param prompt_dict: dict of get_prompt(, return_dict=True) for prompt_type=custom
  :param max_input_tokens:
  :param kwargs:
docstr_tok: ["HF-like","pipeline",",","but","handle","instruction","prompting","and","stopping","(","for","some","models",")",":","param","args",":",":","param","debug",":",":","param","chat",":",":","param","stream_output",":",":","param","sanitize_bot_response",":",":","param","use_prompter",":","Whether","to","use","prompter",".","If","pass","prompt_type",",","will","make","prompter",":","param","prompter",":","prompter",",","can","pass","if","have","already",":","param","prompt_type",":","prompt_type",",","e.g",".","human_bot",".","See","prompt_type","to","model","mapping","in","from","prompter.py",".","If","use_prompter",",","then","will","make","prompter","and","use","it",".",":","param","prompt_dict",":","dict","of","get_prompt","(",",","return_dict=True",")","for","prompt_type=custom",":","param","max_input_tokens",":",":","param","kwargs",":"]
code: def __init__(
      self,
      *args,
      debug=False,
      chat=False,
      stream_output=False,
      sanitize_bot_response=False,
      use_prompter=True,
      prompter=None,
      context="",
      iinput="",
      prompt_type=None,
      prompt_dict=None,
      max_input_tokens=2048 - 256,
      base_model=None,
      stop=None,
      truncation_generation=None,
      verbose=False,
      **kwargs,
  ):
      """
      HF-like pipeline, but handle instruction prompting and stopping (for some models)
      :param args:
      :param debug:
      :param chat:
      :param stream_output:
      :param sanitize_bot_response:
      :param use_prompter: Whether to use prompter.  If pass prompt_type, will make prompter
      :param prompter: prompter, can pass if have already
      :param prompt_type: prompt_type, e.g. human_bot.  See prompt_type to model mapping in from prompter.py.
                          If use_prompter, then will make prompter and use it.
      :param prompt_dict: dict of get_prompt(, return_dict=True) for prompt_type=custom
      :param max_input_tokens:
      :param kwargs:
      """
      super().__init__(*args, **kwargs)
      self.prompt_text = None
      self.use_prompter = use_prompter
      self.prompts = []
      self.prompt_type = prompt_type
      self.prompt_dict = prompt_dict
      self.prompter = prompter
      self.context = context
      self.iinput = iinput
      self.debug = debug
      if self.use_prompter:
          if self.prompter is not None:
              assert self.prompter.prompt_type is not None
          else:
              self.prompter = Prompter(
                  self.prompt_type,
                  self.prompt_dict,
                  debug=debug,
                  stream_output=stream_output,
              )
          self.human = self.prompter.humanstr
          self.bot = self.prompter.botstr
          self.can_stop = True
      else:
          self.prompter = None
          self.human = None
          self.bot = None
          self.can_stop = False
      self.stop = stop
      self.sanitize_bot_response = sanitize_bot_response
      self.max_input_tokens = (
          max_input_tokens  # not for generate, so ok that not kwargs
      )
      self.base_model = base_model
      self.verbose = verbose
      self.truncation_generation = truncation_generation
  
file_path: h2ogpt/spaces/demo/h2oai_pipeline.py
imports: import os
  from transformers import TextGenerationPipeline
  from transformers.pipelines.text_generation import ReturnType
  from stopping import get_stopping
  from prompter import Prompter
label_desc: Use image node_id 1 to create a new H2OTextGenerationPipeline object from inherited base classes: TextGenerationPipeline with example: obj = H2OTextGenerationPipeline()