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: Converts the response from the OpenAI API to a StreamingChunk.
  :param chunk: The chunk returned by the OpenAI API.
  :param choice: The choice returned by the OpenAI API.
  :return: The StreamingChunk.
docstr_tok: ["Converts","the","response","from","the","OpenAI","API","to","a","StreamingChunk",".",":","param","chunk",":","The","chunk","returned","by","the","OpenAI","API",".",":","param","choice",":","The","choice","returned","by","the","OpenAI","API",".",":","return",":","The","StreamingChunk","."]
code: def _build_chunk(self, chunk: Any) -> StreamingChunk:
      """
      Converts the response from the OpenAI API to a StreamingChunk.
      :param chunk: The chunk returned by the OpenAI API.
      :param choice: The choice returned by the OpenAI API.
      :return: The StreamingChunk.
      """
      # function or tools calls are not going to happen in non-chat generation
      # as users can not send ChatMessage with function or tools calls
      choice = chunk.choices[0]
      content = choice.delta.content or ""
      chunk_message = StreamingChunk(content)
      chunk_message.meta.update(
          {
              "model": chunk.model,
              "index": choice.index,
              "finish_reason": choice.finish_reason,
          }
      )
      return chunk_message
  
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 9 for calling the OpenAIGenerator obj's underlying member method code with example usage: obj._build_chunk(chunk) and returns: chunk_message