Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions .gemini/styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,36 @@ LOCATION = "global"
LOCATION = "us-central1"
```

- Don't restart the kernel or use `!pip`, use `%pip` when installing

**Correct**

```sh
%pip install
```

**Incorrect**

```sh
!pip install
```

```sh
!pip3 install
```

```py
app = IPython.Application.instance()
app.kernel.do_shutdown(True)
```

## Golden Rule: Use the Correct and Current SDK

Always use the **Google GenAI SDK** (`google-genai`), which is the unified
Always use the **Google Gen AI SDK** (`google-genai`), which is the unified
standard library for all Gemini API requests (AI Studio/Gemini Developer API
and Vertex AI) as of 2025. Do not use legacy libraries and SDKs.
and Vertex AI) as of 2026. Do not use legacy libraries and SDKs.

- **Library Name:** Google GenAI SDK
- **Library Name:** Google Gen AI SDK
- **Python Package:** `google-genai`
- **Legacy Library**: (`google-generativeai`) is deprecated.

Expand Down
4 changes: 4 additions & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ALDS
Alibaba
alisal
alloydb
Alok
ALPHAFOLD
AMNOSH
amurensis
Expand Down Expand Up @@ -458,6 +459,8 @@ flac
Flahs
Flatform
Flipkart
Flirble
Flirbles
floormat
FLX
fmeasure
Expand Down Expand Up @@ -1017,6 +1020,7 @@ nunique
nvidia
NVIDIA
NVL
NYT
oai
objc
ODb
Expand Down
1 change: 1 addition & 0 deletions .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,4 @@ ignore$
py\.typed$
^\Qaudio/speech/use-cases/storytelling/macbeth_the_sitcom.json\E$
.ruff.toml
^\Q.gemini/styleguide.md\E$
7 changes: 2 additions & 5 deletions .github/actions/spelling/line_forbidden.patterns
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@
# Should be Gemini
\sgemini\s\w

# Should be `Gemini Version Size` (e.g. `Gemini 2.0 Flash`)
# Should be `Gemini Version Size` (e.g. `Gemini 3 Flash`)
\bGemini\s(Pro|Flash|Ultra)\s?\d\.\d\b

# Gemini Size should be capitalized (e.g. `Gemini 2.0 Flash`)
# Gemini Size should be capitalized (e.g. `Gemini 3 Flash`)
\bGemini\s?\d\.\d\s(pro|flash|ultra)\b

# Don't say "Google Gemini" or "Google Gemini"
Expand Down Expand Up @@ -325,6 +325,3 @@ gemini-1\.[05]
# Use the Google Gen AI SDK `google-genai`
google-generativeai
from google import generativeai

# Don't restart the kernel, use `%pip` when installing
app\.kernel\.do_shutdown\(True\)
28 changes: 13 additions & 15 deletions audio/speech/use-cases/storytelling/storytelling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
},
"outputs": [],
"source": [
"%pip install --upgrade -q google-genai google-cloud-texttospeech pydub pandas tqdm"
"%pip install --upgrade -qqq google-genai google-cloud-texttospeech pydub pandas tqdm"
]
},
{
Expand All @@ -170,7 +170,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"id": "BzCUF4oqciKR"
},
Expand All @@ -197,7 +197,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {
"id": "GjSsu6cmUdEx"
},
Expand All @@ -208,7 +208,9 @@
"\n",
"from google import genai\n",
"\n",
"# fmt: off\n",
"PROJECT_ID = \"[your-project-id]\" # @param {type: \"string\", placeholder: \"[your-project-id]\", isTemplate: true}\n",
"# fmt: on\n",
"if not PROJECT_ID or PROJECT_ID == \"[your-project-id]\":\n",
" PROJECT_ID = str(os.environ.get(\"GOOGLE_CLOUD_PROJECT\"))\n",
"\n",
Expand All @@ -233,7 +235,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"id": "vbNgv4q1T2Mi"
},
Expand Down Expand Up @@ -264,7 +266,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {
"id": "PyQmSRbKA8r-"
},
Expand All @@ -274,11 +276,11 @@
"import random\n",
"import re\n",
"\n",
"import pandas as pd\n",
"from IPython.display import Audio\n",
"from google.api_core.client_options import ClientOptions\n",
"from google.cloud import texttospeech_v1beta1 as texttospeech\n",
"from google.genai.types import GenerateContentConfig\n",
"import pandas as pd\n",
"from pydantic import BaseModel\n",
"from pydub import AudioSegment\n",
"from tqdm import tqdm"
Expand All @@ -295,7 +297,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": null,
"metadata": {
"id": "6Pl3un_YciKS"
},
Expand All @@ -318,7 +320,7 @@
"\n",
"SYSTEM_INSTRUCTION = \"\"\"You are a creative and ambitious play writer. Your goal is to write a play for audio performance. Include a narrator character to describe the scenes and actions occurring.\"\"\"\n",
"\n",
"MODEL_ID = \"gemini-2.5-flash\"\n",
"MODEL_ID = \"gemini-3-flash-preview\"\n",
"\n",
"\n",
"class Character(BaseModel):\n",
Expand Down Expand Up @@ -353,7 +355,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": null,
"metadata": {
"id": "kYx2wwhjrmD6"
},
Expand All @@ -378,7 +380,6 @@
" characters: list[Character], voices: list[dict]\n",
") -> dict[str, str]:\n",
" \"\"\"Maps characters to voices based on gender identified by Gemini.\"\"\"\n",
"\n",
" if len(characters) > len(voices):\n",
" print(f\"Too many characters {len(characters)}. Max {len(voices)}\")\n",
"\n",
Expand Down Expand Up @@ -515,9 +516,6 @@
" contents=PROMPT,\n",
" config=GenerateContentConfig(\n",
" system_instruction=SYSTEM_INSTRUCTION,\n",
" max_output_tokens=65535,\n",
" temperature=1.5,\n",
" top_p=0.95,\n",
" response_mime_type=\"application/json\",\n",
" response_schema=Story,\n",
" ),\n",
Expand All @@ -536,7 +534,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"metadata": {
"id": "c3f5cac8983e"
},
Expand Down Expand Up @@ -653,7 +651,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": null,
"metadata": {
"id": "d_ax6LxzciKT"
},
Expand Down
6 changes: 3 additions & 3 deletions gemini/agent-engine/intro_agent_engine.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
"\n",
"<img width=\"40%\" src=\"https://storage.googleapis.com/github-repo/generative-ai/gemini/agent-engine/images/agent-stack-1.png\" alt=\"Components of an agent in Agent Engine on Vertex AI\" />\n",
"\n",
"Here you'll use the Gemini 2.0 model:"
"Here you'll use the Gemini 3 model:"
]
},
{
Expand All @@ -344,7 +344,7 @@
},
"outputs": [],
"source": [
"model = \"gemini-2.0-flash\""
"model = \"gemini-3-flash-preview\""
]
},
{
Expand Down Expand Up @@ -729,7 +729,7 @@
"outputs": [],
"source": [
"## Model variant and version\n",
"model = \"gemini-2.0-flash\"\n",
"model = \"gemini-3-flash-preview\"\n",
"\n",
"## Model safety settings\n",
"from langchain_google_vertexai import HarmBlockThreshold, HarmCategory\n",
Expand Down
38 changes: 17 additions & 21 deletions gemini/batch-prediction/intro_batch_prediction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,6 @@
"### Import libraries\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "fe00fa0b8bb7"
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"import time\n",
"\n",
"import fsspec\n",
"from google import genai\n",
"from google.cloud import bigquery\n",
"from google.genai.types import CreateBatchJobConfig\n",
"import pandas as pd"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -226,8 +208,18 @@
"outputs": [],
"source": [
"import os\n",
"import time\n",
"from datetime import datetime\n",
"\n",
"import fsspec\n",
"import pandas as pd\n",
"from google import genai\n",
"from google.cloud import bigquery\n",
"from google.genai.types import CreateBatchJobConfig\n",
"\n",
"# fmt: off\n",
"PROJECT_ID = \"[your-project-id]\" # @param {type: \"string\", placeholder: \"[your-project-id]\", isTemplate: true}\n",
"# fmt: on\n",
"if not PROJECT_ID or PROJECT_ID == \"[your-project-id]\":\n",
" PROJECT_ID = str(os.environ.get(\"GOOGLE_CLOUD_PROJECT\"))\n",
"\n",
Expand Down Expand Up @@ -312,7 +304,9 @@
},
"outputs": [],
"source": [
"INPUT_DATA = \"gs://cloud-samples-data/generative-ai/batch/batch_requests_for_multimodal_input_2.jsonl\" # @param {type:\"string\"}"
"# fmt: off\n",
"INPUT_DATA = \"gs://cloud-samples-data/generative-ai/batch/batch_requests_for_multimodal_input_2.jsonl\" # @param {type:\"string\"}\n",
"# fmt: on"
]
},
{
Expand Down Expand Up @@ -471,7 +465,7 @@
"Example output:\n",
"\n",
"```json\n",
"{\"status\": \"\", \"processed_time\": \"2024-11-13T14:04:28.376+00:00\", \"request\": {\"contents\": [{\"parts\": [{\"file_data\": null, \"text\": \"List objects in this image.\"}, {\"file_data\": {\"file_uri\": \"gs://cloud-samples-data/generative-ai/image/gardening-tools.jpeg\", \"mime_type\": \"image/jpeg\"}, \"text\": null}], \"role\": \"user\"}], \"generationConfig\": {\"temperature\": 0.4}}, \"response\": {\"candidates\": [{\"avgLogprobs\": -0.10394711927934126, \"content\": {\"parts\": [{\"text\": \"Here's a list of the objects in the image:\\n\\n* **Watering can:** A green plastic watering can with a white rose head.\\n* **Plant:** A small plant (possibly oregano) in a terracotta pot.\\n* **Terracotta pots:** Two terracotta pots, one containing the plant and another empty, stacked on top of each other.\\n* **Gardening gloves:** A pair of striped gardening gloves.\\n* **Gardening tools:** A small trowel and a hand cultivator (hoe). Both are green with black handles.\"}], \"role\": \"model\"}, \"finishReason\": \"STOP\"}], \"modelVersion\": \"gemini-2.0-flash@default\", \"usageMetadata\": {\"candidatesTokenCount\": 110, \"promptTokenCount\": 264, \"totalTokenCount\": 374}}}\n",
"{\"status\": \"\", \"processed_time\": \"2024-11-13T14:04:28.376+00:00\", \"request\": {\"contents\": [{\"parts\": [{\"file_data\": null, \"text\": \"List objects in this image.\"}, {\"file_data\": {\"file_uri\": \"gs://cloud-samples-data/generative-ai/image/gardening-tools.jpeg\", \"mime_type\": \"image/jpeg\"}, \"text\": null}], \"role\": \"user\"}], \"generationConfig\": {\"temperature\": 0.4}}, \"response\": {\"candidates\": [{\"avgLogprobs\": -0.10394711927934126, \"content\": {\"parts\": [{\"text\": \"Here's a list of the objects in the image:\\n\\n* **Watering can:** A green plastic watering can with a white rose head.\\n* **Plant:** A small plant (possibly oregano) in a terracotta pot.\\n* **Terracotta pots:** Two terracotta pots, one containing the plant and another empty, stacked on top of each other.\\n* **Gardening gloves:** A pair of striped gardening gloves.\\n* **Gardening tools:** A small trowel and a hand cultivator (hoe). Both are green with black handles.\"}], \"role\": \"model\"}, \"finishReason\": \"STOP\"}], \"modelVersion\": \"gemini-3-flash-preview@default\", \"usageMetadata\": {\"candidatesTokenCount\": 110, \"promptTokenCount\": 264, \"totalTokenCount\": 374}}}\n",
"```\n"
]
},
Expand Down Expand Up @@ -550,7 +544,9 @@
},
"outputs": [],
"source": [
"INPUT_DATA = \"bq://storage-samples.generative_ai.batch_requests_for_multimodal_input_2\" # @param {type:\"string\"}"
"# fmt: off\n",
"INPUT_DATA = \"bq://storage-samples.generative_ai.batch_requests_for_multimodal_input_2\" # @param {type:\"string\"}\n",
"# fmt: on"
]
},
{
Expand Down
14 changes: 8 additions & 6 deletions gemini/code-execution/intro_code_execution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"id": "JAPoU8Sm5E6e"
},
"source": [
"# Intro to Generating and Executing Python Code with Gemini 2.0\n",
"# Intro to Generating and Executing Python Code with Gemini 3\n",
"\n",
"<table align=\"left\">\n",
" <td style=\"text-align: center\">\n",
Expand Down Expand Up @@ -98,7 +98,7 @@
"source": [
"## Overview\n",
"\n",
"This notebook introduces the code execution capabilities of the [Gemini 2.0 Flash model](https://cloud.google.com/vertex-ai/generative-ai/docs/gemini-v2), a new multimodal generative AI model from Google [DeepMind](https://deepmind.google/). Gemini 2.0 Flash offers improvements in speed, quality, and advanced reasoning capabilities including enhanced understanding, coding, and instruction following.\n",
"This notebook introduces the code execution capabilities of the [Gemini 3 Flash model](https://cloud.google.com/vertex-ai/generative-ai/docs/gemini-v2), a new multimodal generative AI model from Google [DeepMind](https://deepmind.google/). Gemini 3 Flash offers improvements in speed, quality, and advanced reasoning capabilities including enhanced understanding, coding, and instruction following.\n",
"\n",
"## Code Execution\n",
"\n",
Expand All @@ -108,7 +108,7 @@
"\n",
"## Objectives\n",
"\n",
"In this tutorial, you will learn how to generate and execute code using the Gemini API in Vertex AI and the Google Gen AI SDK for Python with the Gemini 2.0 Flash model.\n",
"In this tutorial, you will learn how to generate and execute code using the Gemini API in Vertex AI and the Google Gen AI SDK for Python with the Gemini 3 Flash model.\n",
"\n",
"You will complete the following tasks:\n",
"\n",
Expand Down Expand Up @@ -235,7 +235,9 @@
},
"outputs": [],
"source": [
"# fmt: off\n",
"PROJECT_ID = \"[your-project-id]\" # @param {type: \"string\", placeholder: \"[your-project-id]\", isTemplate: true}\n",
"# fmt: on\n",
"if not PROJECT_ID or PROJECT_ID == \"[your-project-id]\":\n",
" PROJECT_ID = str(os.environ.get(\"GOOGLE_CLOUD_PROJECT\"))\n",
"\n",
Expand All @@ -259,11 +261,11 @@
"id": "x1vpnyk-q-fz"
},
"source": [
"## Working with code execution in Gemini 2.0\n",
"## Working with code execution in Gemini 3\n",
"\n",
"### Load the Gemini model\n",
"\n",
"The following code loads the Gemini 2.0 Flash model. You can learn about all Gemini models on Vertex AI by visiting the [documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models):"
"The following code loads the Gemini 3 Flash model. You can learn about all Gemini models on Vertex AI by visiting the [documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models):"
]
},
{
Expand All @@ -274,7 +276,7 @@
},
"outputs": [],
"source": [
"MODEL_ID = \"gemini-2.0-flash-001\" # @param {type: \"string\"}"
"MODEL_ID = \"gemini-3-flash-preview\" # @param {type: \"string\"}"
]
},
{
Expand Down
Loading
Loading