class_docstr: Generator based on a Hugging Face model.
  This component provides an interface to generate text using a Hugging Face model that runs locally.
  
  Usage example:
  ```python
  from haystack.components.generators import HuggingFaceLocalGenerator
  
  generator = HuggingFaceLocalGenerator(model="google/flan-t5-large",
                                        task="text2text-generation",
                                        generation_kwargs={
                                          "max_new_tokens": 100,
                                          "temperature": 0.9,
                                          })
  
  print(generator.run("Who is the best American actor?"))
  # {'replies': ['John Cusack']}
  ```
docstr: Run the text generation model on the given prompt.
  
  :param prompt: A string representing the prompt.
  :param generation_kwargs: Additional keyword arguments for text generation.
  :return: A dictionary containing the generated replies.
code: def run(
      self,
      prompt: str,
      generation_kwargs: Optional[Dict[str, Any]] = None,
  ):
      """
      Run the text generation model on the given prompt.
  
      :param prompt: A string representing the prompt.
      :param generation_kwargs: Additional keyword arguments for text generation.
      :return: A dictionary containing the generated replies.
      """
      if self.pipeline is None:
          raise RuntimeError(
              "The generation model has not been loaded. Please call warm_up() before running."
          )
  
      if not prompt:
          return {"replies": []}
  
      # merge generation kwargs from init method with those from run method
      updated_generation_kwargs = {
          **self.generation_kwargs,
          **(generation_kwargs or {}),
      }
  
      output = self.pipeline(
          prompt,
          stopping_criteria=self.stopping_criteria_list,
          **updated_generation_kwargs,
      )
      replies = [
          o["generated_text"] for o in output if "generated_text" in o
      ]
  
      if self.stop_words:
          # the output of the pipeline includes the stop word
          replies = [
              reply.replace(stop_word, "").rstrip()
              for reply in replies
              for stop_word in self.stop_words
          ]
  
      return {"replies": replies}
  
file_path: haystack/haystack/components/generators/hugging_face_local.py
imports: import logging
  from typing import Any, Dict, List, Literal, Optional, Union
  from haystack import component, default_to_dict, default_from_dict
  from haystack.components.generators.hf_utils import StopWordsCriteria
  from haystack.lazy_imports import LazyImport
label_desc: Use image node_id 6 for calling the HuggingFaceLocalGenerator obj's underlying member method code with example usage: obj.run(prompt, generation_kwargs) and returns: dict, dict