docstr: Generate text completions with the local LLM.
      Args:
          df (pd.DataFrame): The input DataFrame containing data to predict.
          args (Optional[Dict]): Additional arguments for prediction parameters.
      Returns:
          pd.DataFrame: The DataFrame containing row-wise text completions.
code: def predict(
      self, df: pd.DataFrame, args: Optional[Dict] = None
  ) -> pd.DataFrame:
      """
      Generate text completions with the local LLM.
          Args:
              df (pd.DataFrame): The input DataFrame containing data to predict.
              args (Optional[Dict]): Additional arguments for prediction parameters.
          Returns:
              pd.DataFrame: The DataFrame containing row-wise text completions.
      """
      # setup
      pred_args = args.get("predict_params", {})
      args = self.model_storage.json_get("args")
      model_name, target_col = args["model_name"], args["target"]
      prompt_template = pred_args.get(
          "prompt_template",
          args.get(
              "prompt_template",
              "Answer the following question: {{{{text}}}}",
          ),
      )
      # TODO v2: add support for overriding modelfile params (e.g. temperature)
  
      # prepare prompts
      prompts, empty_prompt_ids = get_completed_prompts(
          prompt_template, df
      )
      df["__mdb_prompt"] = prompts
  
      # call llm
      completions = []
      for i, row in df.iterrows():
          if i not in empty_prompt_ids:
              raw_output = requests.post(
                  OllamaHandler.SERVE_URL + "/api/generate",
                  json={
                      "model": args["model_name"],
                      "prompt": row["__mdb_prompt"],
                  },
              )
              out_tokens = raw_output.content.decode().split(
                  "\n"
              )  # stream of output tokens
  
              tokens = []
              for o in out_tokens:
                  if o != "":
                      # TODO v2: add support for storing `context` short conversational memory
                      info = json.loads(o)
                      if "response" in info:
                          token = info["response"]
                          tokens.append(token)
  
              completions.append("".join(tokens))
          else:
              completions.append("")
  
      # consolidate output
      data = pd.DataFrame(completions)
      data.columns = [target_col]
      return data
  
file_path: mindsdb/mindsdb/integrations/handlers/ollama_handler/ollama_handler.py
imports: import json
  import requests
  from typing import Dict, Optional
  import pandas
  from mindsdb.integrations.libs.base import BaseMLEngine
  from mindsdb.integrations.libs.llm_utils import get_completed_prompts
label_desc: Use image node_id 3 for calling the OllamaHandler obj's underlying member method code with example usage: obj.predict(df, args) and returns: data