VertexAIGeminiGenerator

Generate text using Google Gemini models.

Basic Information

  • Pipeline type: Query
  • Components that can precede it in a pipeline:
  • Components that can follow it in a pipeline: PromptBuilder
  • Required inputs:
    • "parts": A variadic list containing a mix of images, audio, video, and text to prompt the Gemini model.
  • Outputs:
    A dictionary with the following keys:
    • "replies": A list of generated texts.

Overview

VertexAIGeminiGenerator uses the gemini-pro-vision model by default, but you can replace it with any other supported model. Supported models are:

  • gemini-pro
  • gemini-pro-vision

To prompt with images, set the model to gemini-pro-vision. For function calling, use gemini-pro.

Authentication

VertexAIGeminiGenerator authenticates using Google Cloud Application Default Credentials (ADCs). For more information, see Google documentation. Use an account that can access projects authorized to use Google Vertex AI endpoints.

Usage Example


Parameters

ParameterTypePossible valuesDescription
modelStringDefault: gemini-pro-visionName of the model to use.
Required.
project_idStringID of the GCP project to use. You can find your project ID in the GCP resource manager, or locally by running gcloud projects list in your terminal. For information on using gcloud CLI, see the official documentation.
Required.
locationStringDefault: NoneThe default location to use when making API calls.
Optional.
generation_configUnion of GenerationConfig and a dictionary of string and anyDefault: NoneThe generation configuraiton to use. Can be a [GenerationConfig](https://cloud.google.com/python/docs/reference/aiplatform/latest/vertexai.preview.generative_models.GenerationConfig) object or a dictionary of parameters. Accepted fields include: temperature, top_p, top_k, candidate_count, max_output_tokens, stop_sequences.
Optional.
safety_settingsDictionary of HarmCategory and HarmBlockThresholdDefault: NoneThe safety settings to use. For details, see the documentation for HarmBlockThreshold and HarmCategory.
Optional.
toolsList of toolsDefault: NoneList of tools to use when generating content. See the Tool documentation for details.
Optional.