code: def _gemini_vision_convert_messages(messages: list):
      """
      Converts given messages for GPT-4 Vision to Gemini format.
  
      Args:
          messages (list): The messages to convert. Each message can be a dictionary with a "content" key. The content can be a string or a list of elements. If it is a string, it will be concatenated to the prompt. If it is a list, each element will be processed based on its type:
              - If the element is a dictionary with a "type" key equal to "text", its "text" value will be concatenated to the prompt.
              - If the element is a dictionary with a "type" key equal to "image_url", its "image_url" value will be added to the list of images.
  
      Returns:
          tuple: A tuple containing the prompt (a string) and the processed images (a list of objects representing the images).
      """
      try:
          from PIL import Image
      except:
          raise Exception(
              "gemini image conversion failed please run `pip install Pillow`"
          )
  
      try:
          # given messages for gpt-4 vision, convert them for gemini
          # https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-started/intro_gemini_python.ipynb
          prompt = ""
          images = []
          for message in messages:
              if isinstance(message["content"], str):
                  prompt += message["content"]
              elif isinstance(message["content"], list):
                  # see https://docs.litellm.ai/docs/providers/openai#openai-vision-models
                  for element in message["content"]:
                      if isinstance(element, dict):
                          if element["type"] == "text":
                              prompt += element["text"]
                          elif element["type"] == "image_url":
                              image_url = element["image_url"]["url"]
                              images.append(image_url)
          # processing images passed to gemini
          processed_images = []
          for img in images:
              if "https:/" in img:
                  # Case 1: Image from URL
                  image = _load_image_from_url(img)
                  processed_images.append(image)
              else:
                  # Case 2: Image filepath (e.g. temp.jpeg) given
                  image = Image.open(img)
                  processed_images.append(image)
          content = [prompt] + processed_images
          return content
      except Exception as e:
          raise e
  
imports: from enum import Enum
  import requests, traceback
  import json
  from jinja2 import Template, exceptions, Environment, meta
  from typing import Optional, Any
label_desc: Use image node_id 17 for calling a global function with example usage: _gemini_vision_convert_messages(messages) and returns: content