docstr: The function takes in a list of strings and returns a list of predictions
  
  Args:
    text (Union[List[str], str]): The text to be classified.
    as_argilla_records (bool): If True, the prediction will be returned as an Argilla record. If
  False, the prediction will be returned as a string. Defaults to True
  
  Returns:
    A list of predictions
docstr_tok: ["The","function","takes","in","a","list","of","strings","and","returns","a","list","of","predictions","Args",":","text","(","Union","[","List","[","str","]",",","str","]",")",":","The","text","to","be","classified",".","as_argilla_records","(","bool",")",":","If","True",",","the","prediction","will","be","returned","as","an","Argilla","record",".","If","False",",","the","prediction","will","be","returned","as","a","string",".","Defaults","to","True","Returns",":","A","list","of","predictions"]
code: def predict(
      self,
      text: Union[List[str], str],
      as_argilla_records: bool = True,
      **kwargs,
  ) -> Union[List, str]:
      """
      The function takes in a list of strings and returns a list of predictions
  
      Args:
        text (Union[List[str], str]): The text to be classified.
        as_argilla_records (bool): If True, the prediction will be returned as an Argilla record. If
      False, the prediction will be returned as a string. Defaults to True
  
      Returns:
        A list of predictions
      """
  
      import openai
  
      responses = []
      was_string = False
  
      if self.__legacy:
          if isinstance(text, str):
              text = [text]
              was_string = True
  
          if isinstance(self._settings, TextClassificationSettings):
              for kwarg in [
                  "logprobs",
                  "max_tokens",
                  "temperature",
                  "n",
              ]:
                  if kwarg in kwargs:
                      del kwargs[kwarg]
                      self._logger.warning(
                          f"Argument `{kwarg}` has default value for text classification. Deleting it."
                      )
              kwargs["logprobs"] = len(self._settings.label_schema)
              kwargs["max_tokens"] = 1
              kwargs["temperature"] = 0
              kwargs["n"] = 1
          else:
              if "stop" in kwargs:
                  del kwargs[kwarg]
              self._logger.warning(
                  "Argument `stop` has default value for text classification. Deleting it."
              )
              kwargs["stop"] = self._end_token
              if "logprobs" not in kwargs:
                  kwargs["logprobs"] = 1
  
          for entry in text:
              prompt = f"{entry.strip()}{self._separator}"
              response = openai.Completion.create(
                  model=self._model, prompt=prompt, **kwargs
              )
  
              if isinstance(self._settings, TextClassificationSettings):
                  logprobs = response["choices"][0]["logprobs"][
                      "top_logprobs"
                  ][0]
                  keys = [
                      self._settings.id2label[int(key.strip())]
                      for key in list(logprobs.keys())
                  ]
                  values = np.exp(list(logprobs.values()))
                  response["choices"][0]["logprobs"]["top_logprobs"][
                      0
                  ] = dict(zip(keys, values))
                  if as_argilla_records:
                      response = self._record_class(
                          text=entry, prediction=list(zip(keys, values))
                      )
              elif isinstance(
                  self._settings, TokenClassificationSettings
              ):
                  raise NotImplementedError(
                      "TokenClassification is not supported yet."
                  )
              else:
                  if as_argilla_records:
                      predictions = [
                          choice["text"]
                          for choice in response["choices"]
                      ]
                      response = self._record_class(
                          text=entry, prediction=predictions
                      )
  
              responses.append(response)
      else:
          raise NotImplementedError(
              f"Prediction for the new OpenAI API is not supported yet. Take a look at their docs https://platform.openai.com/docs/api-reference/chat/create and use `model={self._model}`"
          )
  
      if was_string:
          return responses[0]
      else:
          return responses
  
imports: import logging
  import os
  import time
  from typing import List, Optional, Union
  import numpy
  from argilla._constants import OPENAI_END_TOKEN, OPENAI_LEGACY_MODELS, OPENAI_SEPARATOR, OPENAI_WHITESPACE
  from argilla.client.models import TextClassificationRecord, TokenClassificationRecord
  from argilla.datasets import TextClassificationSettings, TokenClassificationSettings
  from argilla.training.base import ArgillaTrainerSkeleton
  from argilla.training.utils import filter_allowed_args
  from argilla.utils.dependency import require_dependencies
label_desc: Use image node_id 9 for calling the ArgillaOpenAITrainer obj's underlying member method code with example usage: obj.predict(text, as_argilla_records) and returns: responses, responses