Use Google Cloud’s AI Platform to access the Gemini model.

Prerequisites

  1. Install the Google Cloud SDK
  2. Create a Google Cloud project
  3. Enable the AI Platform API
  4. Authenticate with Google Cloud
gcloud auth application-default login

Usage

Use Gemini with your Assistant:

import vertexai
from phi.assistant import Assistant
from phi.llm.gemini import Gemini

# *********** Initialize VertexAI ***********
vertexai.init(project=getenv("PROJECT_ID"), location=getenv("LOCATION"))

assistant = Assistant(
    llm=Gemini(model="gemini-1.0-pro-vision"),
    description="You help people with their health and fitness goals.",
)
assistant.print_response("Share a quick healthy breakfast recipe.", markdown=True)

Params

name
str
default: "Gemini"

The name identifier for the assistant.

model
str
default: "gemini-1.0-pro-vision"

The specific model ID used for generating responses.

generation_config
Any

Configuration settings for the generation process, such as parameters for controlling output behavior.

safety_settings
Any

Settings related to safety measures, ensuring the generation of appropriate and safe content.

function_declarations
List[FunctionDeclaration]

A list of function declarations that the model can utilize during the response generation process.

generative_model
GenerativeModel

The generative model instance used for producing responses.