class_docstr: Enables text generation using OpenAI's large language models (LLMs). It supports gpt-4 and gpt-3.5-turbo
  family of models.
  
  Users can pass any text generation parameters valid for the `openai.ChatCompletion.create` method
  directly to this component via the `**generation_kwargs` parameter in __init__ or the `**generation_kwargs`
  parameter in `run` method.
  
  For more details on the parameters supported by the OpenAI API, refer to the OpenAI
  [documentation](https://platform.openai.com/docs/api-reference/chat).
  
  ```python
  from haystack.components.generators import OpenAIGenerator
  client = OpenAIGenerator()
  response = client.run("What's Natural Language Processing? Be brief.")
  print(response)
  
  >> {'replies': ['Natural Language Processing (NLP) is a branch of artificial intelligence that focuses on
  >> the interaction between computers and human language. It involves enabling computers to understand, interpret,
  >> and respond to natural human language in a way that is both meaningful and useful.'], 'meta': [{'model':
  >> 'gpt-3.5-turbo-0613', 'index': 0, 'finish_reason': 'stop', 'usage': {'prompt_tokens': 16,
  >> 'completion_tokens': 49, 'total_tokens': 65}}]}
  ```
  
   Key Features and Compatibility:
       - **Primary Compatibility**: Designed to work seamlessly with gpt-4, gpt-3.5-turbo family of models.
       - **Streaming Support**: Supports streaming responses from the OpenAI API.
       - **Customizability**: Supports all parameters supported by the OpenAI API.
  
   Input and Output Format:
       - **String Format**: This component uses the strings for both input and output.
docstr: Check the `finish_reason` returned with the OpenAI completions.
  If the `finish_reason` is `length`, log a warning to the user.
  :param message: The message returned by the LLM.
docstr_tok: ["Check","the","`","finish_reason","`","returned","with","the","OpenAI","completions",".","If","the","`","finish_reason","`","is","`","length","`",",","log","a","warning","to","the","user",".",":","param","message",":","The","message","returned","by","the","LLM","."]
code: def _check_finish_reason(self, message: ChatMessage) -> None:
      """
      Check the `finish_reason` returned with the OpenAI completions.
      If the `finish_reason` is `length`, log a warning to the user.
      :param message: The message returned by the LLM.
      """
      if message.meta["finish_reason"] == "length":
          logger.warning(
              "The completion for index %s has been truncated before reaching a natural stopping point. "
              "Increase the max_tokens parameter to allow for longer completions.",
              message.meta["index"],
          )
      if message.meta["finish_reason"] == "content_filter":
          logger.warning(
              "The completion for index %s has been truncated due to the content filter.",
              message.meta["index"],
          )
  
imports: import dataclasses
  import logging
  import warnings
  from typing import Optional, List, Callable, Dict, Any, Union
  from openai import OpenAI, Stream
  from openai.types.chat import ChatCompletionChunk, ChatCompletion
  from haystack import component, default_from_dict, default_to_dict
  from haystack.components.generators.utils import serialize_callback_handler, deserialize_callback_handler
  from haystack.dataclasses import StreamingChunk, ChatMessage
label_desc: Use image node_id 10 for calling the OpenAIGenerator obj's underlying member method code with example usage: obj._check_finish_reason(message) without return types