class_docstr: Twelve Labs API handler implementation.
class_docstr_tok: ["Twelve","Labs","API","handler","implementation","."]
docstr: Predicts the target column for the given data. This method is called when making predictions.
  
  Parameters
  ----------
  df : pd.DataFrame, Optional
      DataFrame containing the data to be used in making predictions. This can include the column containing the queries to be run against the index.
  
  args : Dict, Optional
      Additional arguments.
docstr_tok: ["Predicts","the","target","column","for","the","given","data",".","This","method","is","called","when","making","predictions",".","Parameters","--","--","--","--","--","df",":","pd.DataFrame",",","Optional","DataFrame","containing","the","data","to","be","used","in","making","predictions",".","This","can","include","the","column","containing","the","queries","to","be","run","against","the","index",".","args",":","Dict",",","Optional","Additional","arguments","."]
code: def predict(
      self,
      df: Optional[pd.DataFrame] = None,
      args: Optional[Dict] = None,
  ) -> None:
      """
      Predicts the target column for the given data. This method is called when making predictions.
  
      Parameters
      ----------
      df : pd.DataFrame, Optional
          DataFrame containing the data to be used in making predictions. This can include the column containing the queries to be run against the index.
  
      args : Dict, Optional
          Additional arguments.
  
      """
  
      # get args from model_storage
      args = self.model_storage.json_get("args")
  
      # get api key
      api_key = get_api_key(
          api_name=self.name,
          create_args=args,
          engine_storage=self.engine_storage,
      )
  
      # initialize TwelveLabsAPIClient
      twelve_labs_api_client = TwelveLabsAPIClient(api_key=api_key)
  
      # get search query
      # TODO: support multiple queries
      query = df[args["query_column"]].tolist()[0]
  
      # check if task is search
      if args["task"] == "search":
          # search for query in index
          data = twelve_labs_api_client.search_index(
              index_id=args["index_id"],
              query=query,
              search_options=args["search_options"],
          )
  
          # TODO: pick only the necessary columns?
          # TODO: structure nested columns?
          # metadata = ['score', 'start', 'end', 'video_id', 'confidence']
          # df_metadata = pd.json_normalize(data, record_path='metadata', meta=metadata, record_prefix='metadata_')
          # df_modules = pd.json_normalize(data, record_path='modules', meta=metadata, record_prefix='modules_')
          # df_predictions = pd.merge(df_metadata, df_modules, on=metadata)
          # return df_predictions
          return pd.json_normalize(data).add_prefix(
              args["target"] + "_"
          )
  
      else:
          raise NotImplementedError(
              f"Task {args['task']} is not supported."
          )
  
file_path: mindsdb/mindsdb/integrations/handlers/twelve_labs_handler/twelve_labs_handler.py
imports: import pandas
  from typing import Optional, Dict
  from mindsdb.utilities import log
  from mindsdb.integrations.libs.base import BaseMLEngine
  from mindsdb.integrations.utilities.handler_utils import get_api_key
  from mindsdb.integrations.libs.api_handler_exceptions import MissingConnectionParams
  from mindsdb.integrations.handlers.twelve_labs_handler.settings import TwelveLabsHandlerModel
  from mindsdb.integrations.handlers.twelve_labs_handler.twelve_labs_api_client import TwelveLabsAPIClient
label_desc: Use image node_id 4 for calling the TwelveLabsHandler obj's underlying member method code with example usage: obj.predict(df, args) and returns: pd