VertexAICodeGenerator

Use VertexAICodeGenerator to generate code with a Google Vertex AI models.

Basic Information

  • Pipeline type: Query
  • Components that can precede it in a pipeline:
  • Components that can follow it in a pipeline:
  • Required inputs:
    • "prefix": A string containing code preceding the current point.
  • Optional inputs:
    • "suffix": A string containing code after the current point.
  • Outputs:
    A dictionary with the following keys:
    • "replies": A list of generated code snippets.

Overview

VertexAICodeGenerator uses the code-bison model by default but you can replace it with any other supported model. Supported models are:

  • code-bison
  • code-bison-32k
  • code-gecko

Authentication

VertexAICodeGenerator 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: code-bisonName 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.
kwargsDictionaryAdditional keyword arguments to pass to the model.