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).
  
      Raises:
          VertexAIError: If the import of the 'vertexai' module fails, indicating that 'google-cloud-aiplatform' needs to be installed.
          Exception: If any other exception occurs during the execution of the function.
  
      Note:
          This function is based on the code from the 'gemini/getting-started/intro_gemini_python.ipynb' notebook in the 'generative-ai' repository on GitHub.
          The supported MIME types for images include 'image/png' and 'image/jpeg'.
  
      Examples:
          >>> messages = [
          ...     {"content": "Hello, world!"},
          ...     {"content": [{"type": "text", "text": "This is a text message."}, {"type": "image_url", "image_url": "example.com/image.png"}]},
          ... ]
          >>> _gemini_vision_convert_messages(messages)
          ('Hello, world!This is a text message.', [<Part object>, <Part object>])
      """
      try:
          import vertexai
      except:
          raise VertexAIError(
              status_code=400,
              message="vertexai import failed please run `pip install google-cloud-aiplatform`",
          )
      try:
          from vertexai.preview.language_models import (
              ChatModel,
              CodeChatModel,
              InputOutputTextPair,
          )
          from vertexai.language_models import (
              TextGenerationModel,
              CodeGenerationModel,
          )
          from vertexai.preview.generative_models import (
              GenerativeModel,
              Part,
              GenerationConfig,
              Image,
          )
  
          # 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 "gs://" in img:
                  # Case 1: Images with Cloud Storage URIs
                  # The supported MIME types for images include image/png and image/jpeg.
                  part_mime = (
                      "image/png" if "png" in img else "image/jpeg"
                  )
                  google_clooud_part = Part.from_uri(
                      img, mime_type=part_mime
                  )
                  processed_images.append(google_clooud_part)
              elif "https:/" in img:
                  # Case 2: Images with direct links
                  image = _load_image_from_url(img)
                  processed_images.append(image)
              elif ".mp4" in img and "gs://" in img:
                  # Case 3: Videos with Cloud Storage URIs
                  part_mime = "video/mp4"
                  google_clooud_part = Part.from_uri(
                      img, mime_type=part_mime
                  )
                  processed_images.append(google_clooud_part)
          return prompt, processed_images
      except Exception as e:
          raise e
  
file_path: litellm/litellm/llms/vertex_ai.py
imports: import os, types
  import json
  from enum import Enum
  import requests
  import time
  from typing import Callable, Optional
  from litellm.utils import ModelResponse, Usage, CustomStreamWrapper
  import litellm, uuid
  import httpx
label_desc: Use image node_id 3 for calling a global function with example usage: _gemini_vision_convert_messages(messages) and returns: prompt,  processed_images