class_docstr: LiteLLMHandler is a MindsDB handler for litellm - https://docs.litellm.ai/docs/
class_docstr_tok: ["LiteLLMHandler","is","a","MindsDB","handler","for","litellm","-","https",":","\/\/docs.litellm.ai\/docs\/"]
docstr: Dispatch is getting args from model_storage, validating args and running completion
docstr_tok: ["Dispatch","is","getting","args","from","model_storage",",","validating","args","and","running","completion"]
code: def predict(self, df: pd.DataFrame = None, args: dict = None):
      """
      Dispatch is getting args from model_storage, validating args and running completion
      """
  
      input_args = self.model_storage.json_get("args")
  
      # validate args
      args = CompletionParameters(**input_args).dict()
  
      # build messages
      self._build_messages(args, df)
  
      # remove prompt_template from args
      args.pop("prompt_template", None)
  
      if len(args["messages"]) > 1:
          # if more than one message, use batch completion
          responses = batch_completion(**args)
          return pd.DataFrame(
              {
                  "result": [
                      response.choices[0].message.content
                      for response in responses
                  ]
              }
          )
  
      # run completion
      response = completion(**args)
  
      return pd.DataFrame(
          {"result": [response.choices[0].message.content]}
      )
  
file_path: mindsdb/mindsdb/integrations/handlers/litellm_handler/litellm_handler.py
imports: import ast
  from typing import Dict, Optional, List
  import pandas
  from mindsdb.integrations.libs.base import BaseMLEngine
  from mindsdb.utilities import log
  from mindsdb.integrations.handlers.litellm_handler.settings import CompletionParameters
  from litellm import completion, batch_completion
label_desc: Use image node_id 4 for calling the LiteLLMHandler obj's underlying member method code with example usage: obj.predict(df, args) and returns: pd, pd