From e308643c77f5db3834f60c84162de920076569a2 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Mon, 20 May 2024 12:57:44 -0700 Subject: [PATCH] Update model names to use gemini-1.5-flash-latest (#145) --- README.md | 4 ++-- packages/main/README.md | 4 ++-- .../test-integration/node/count-tokens.test.ts | 2 +- .../node/generate-content-multimodal.test.ts | 2 +- .../node/generate-content-tools.test.ts | 4 ++-- .../node/generate-content.test.ts | 10 +++++----- .../node/start-chat-tools.test.ts | 2 +- .../test-integration/node/start-chat.test.ts | 8 ++++---- packages/main/test-integration/web/index.test.ts | 16 ++++++++-------- samples/node/README.md | 4 ++-- samples/node/advanced-chat.js | 3 +-- samples/node/advanced-function-calling.js | 3 +-- samples/node/advanced-text-and-images.js | 3 +-- samples/node/advanced-text.js | 3 +-- samples/node/file-upload.js | 3 +-- samples/node/simple-chat.js | 3 +-- samples/node/simple-config.js | 3 +-- samples/node/simple-text-and-images.js | 3 +-- samples/node/simple-text.js | 3 +-- samples/web/chat.html | 2 +- samples/web/index.html | 2 +- samples/web/utils/shared.js | 1 - 22 files changed, 39 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 13e71b2d..c6a3e2d2 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ For example, with just a few lines of code, you can access Gemini's multimodal c For Node.js: ```js -const model = genAI.getGenerativeModel({ model: "gemini-pro-vision" }); +const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest" }); const prompt = "Does this look store-bought or homemade?"; const image = { @@ -36,7 +36,7 @@ console.log(result.response.text()); For web: ```js -const model = genAI.getGenerativeModel({ model: "gemini-pro-vision" }); +const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest" }); const prompt = "Does this look store-bought or homemade?"; const image = { diff --git a/packages/main/README.md b/packages/main/README.md index 34cc88d3..003ae41f 100644 --- a/packages/main/README.md +++ b/packages/main/README.md @@ -20,7 +20,7 @@ For example, with just a few lines of code, you can access Gemini's multimodal c For Node.js: ``` -const model = genAI.getGenerativeModel({ model: "gemini-pro-vision" }); +const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest" }); const prompt = "Does this look store-bought or homemade?"; const image = { @@ -36,7 +36,7 @@ console.log(result.response.text()); For web: ``` -const model = genAI.getGenerativeModel({ model: "gemini-pro-vision" }); +const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest" }); const prompt = "Does this look store-bought or homemade?"; const image = { diff --git a/packages/main/test-integration/node/count-tokens.test.ts b/packages/main/test-integration/node/count-tokens.test.ts index cdf46889..7e8dda45 100644 --- a/packages/main/test-integration/node/count-tokens.test.ts +++ b/packages/main/test-integration/node/count-tokens.test.ts @@ -31,7 +31,7 @@ describe("countTokens", function () { it("counts tokens right", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, diff --git a/packages/main/test-integration/node/generate-content-multimodal.test.ts b/packages/main/test-integration/node/generate-content-multimodal.test.ts index 85c95616..d5aead03 100644 --- a/packages/main/test-integration/node/generate-content-multimodal.test.ts +++ b/packages/main/test-integration/node/generate-content-multimodal.test.ts @@ -38,7 +38,7 @@ describe("generateContent - multimodal", function () { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const base64Image = imageBuffer.toString("base64"); const model = genAI.getGenerativeModel({ - model: "gemini-pro-vision", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, diff --git a/packages/main/test-integration/node/generate-content-tools.test.ts b/packages/main/test-integration/node/generate-content-tools.test.ts index 62e5e420..d10394bb 100644 --- a/packages/main/test-integration/node/generate-content-tools.test.ts +++ b/packages/main/test-integration/node/generate-content-tools.test.ts @@ -35,7 +35,7 @@ describe("generateContent - tools", function () { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel( { - model: "gemini-pro", + model: "gemini-1.5-flash-latest", tools: [ { functionDeclarations: [ @@ -185,7 +185,7 @@ describe("generateContent - tools", function () { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel( { - model: "gemini-pro", + model: "gemini-1.5-flash-latest", tools: [ { functionDeclarations: [ diff --git a/packages/main/test-integration/node/generate-content.test.ts b/packages/main/test-integration/node/generate-content.test.ts index e956827f..ead4ef81 100644 --- a/packages/main/test-integration/node/generate-content.test.ts +++ b/packages/main/test-integration/node/generate-content.test.ts @@ -38,7 +38,7 @@ describe("generateContent", function () { it.skip("streaming - count numbers", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", generationConfig: { temperature: 0, candidateCount: 1, @@ -65,7 +65,7 @@ describe("generateContent", function () { it("stream true, blocked", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -94,7 +94,7 @@ describe("generateContent", function () { it("stream true, invalid argument", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -116,7 +116,7 @@ describe("generateContent", function () { it("non-streaming, simple interface", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -132,7 +132,7 @@ describe("generateContent", function () { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel( { - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, diff --git a/packages/main/test-integration/node/start-chat-tools.test.ts b/packages/main/test-integration/node/start-chat-tools.test.ts index f238775b..2ceef3d4 100644 --- a/packages/main/test-integration/node/start-chat-tools.test.ts +++ b/packages/main/test-integration/node/start-chat-tools.test.ts @@ -73,7 +73,7 @@ describe("startChat - tools", function () { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel( { - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, diff --git a/packages/main/test-integration/node/start-chat.test.ts b/packages/main/test-integration/node/start-chat.test.ts index c7217d26..935f2e7d 100644 --- a/packages/main/test-integration/node/start-chat.test.ts +++ b/packages/main/test-integration/node/start-chat.test.ts @@ -31,7 +31,7 @@ describe("startChat", function () { it("stream false", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -54,7 +54,7 @@ describe("startChat", function () { it("stream true, blocked", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -94,7 +94,7 @@ describe("startChat", function () { it("stream true", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -130,7 +130,7 @@ describe("startChat", function () { it("stream true, try to send message before previous stream is done", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, diff --git a/packages/main/test-integration/web/index.test.ts b/packages/main/test-integration/web/index.test.ts index 3dcfbfcd..3c527d5f 100644 --- a/packages/main/test-integration/web/index.test.ts +++ b/packages/main/test-integration/web/index.test.ts @@ -27,7 +27,7 @@ describe("generateContent", function () { it("stream true, blocked", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -56,7 +56,7 @@ describe("generateContent", function () { it("non-streaming, simple interface", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -72,7 +72,7 @@ describe("generateContent", function () { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel( { - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -94,7 +94,7 @@ describe("startChat", function () { it("stream false", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -117,7 +117,7 @@ describe("startChat", function () { it("stream true, blocked", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -157,7 +157,7 @@ describe("startChat", function () { it("stream true", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -193,7 +193,7 @@ describe("startChat", function () { it("stream true, try to send message before previous stream is done", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, @@ -241,7 +241,7 @@ describe("countTokens", function () { it("counts tokens right", async () => { const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY || ""); const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_HARASSMENT, diff --git a/samples/node/README.md b/samples/node/README.md index a75a1875..0d7c0399 100644 --- a/samples/node/README.md +++ b/samples/node/README.md @@ -17,8 +17,8 @@ This sample assumes that you're providing an `API_KEY` environment variable. ### Simple examples -- `simple-text.js` - Text-only input, using the `gemini-pro` model -- `simple-text-and-images.js` - Text-and-images input (multimodal), using the `gemini-pro-vision` model +- `simple-text.js` - Text-only input +- `simple-text-and-images.js` - Text-and-images input (multimodal) - `simple-chat.js` - Dialog language tasks, using `ChatSession` class - `simple-config.js` - Configuring model parameters - `simple-embedding.js` - Embeddings, using the `embedding-001` model diff --git a/samples/node/advanced-chat.js b/samples/node/advanced-chat.js index 52b7b304..4c6db56d 100644 --- a/samples/node/advanced-chat.js +++ b/samples/node/advanced-chat.js @@ -22,8 +22,7 @@ import { } from "./utils/common.js"; async function run() { - // For dialog language tasks (like chat), use the gemini-pro model - const model = genAI.getGenerativeModel({ model: "gemini-pro" }); + const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest" }); const chat = model.startChat({ history: [ diff --git a/samples/node/advanced-function-calling.js b/samples/node/advanced-function-calling.js index f2a373cc..c7295342 100644 --- a/samples/node/advanced-function-calling.js +++ b/samples/node/advanced-function-calling.js @@ -46,9 +46,8 @@ async function run() { }, ]; - // For text-only inputs, use the gemini-pro model const model = genAI.getGenerativeModel( - { model: "gemini-pro", tools }, + { model: "gemini-1.5-flash-latest", tools }, { apiVersion: "v1beta" }, ); diff --git a/samples/node/advanced-text-and-images.js b/samples/node/advanced-text-and-images.js index c5ee023a..9abcade6 100644 --- a/samples/node/advanced-text-and-images.js +++ b/samples/node/advanced-text-and-images.js @@ -23,9 +23,8 @@ import { } from "./utils/common.js"; async function run() { - // For text-and-images inputs (multimodal), use the gemini-pro-vision model const model = genAI.getGenerativeModel({ - model: "gemini-pro-vision", + model: "gemini-1.5-flash-latest", generationConfig: { temperature: 0, }, diff --git a/samples/node/advanced-text.js b/samples/node/advanced-text.js index abf9ba03..e2577435 100644 --- a/samples/node/advanced-text.js +++ b/samples/node/advanced-text.js @@ -19,9 +19,8 @@ import { HarmBlockThreshold, HarmCategory } from "@google/generative-ai"; import { genAI, displayTokenCount, streamToStdout } from "./utils/common.js"; async function run() { - // For text-only inputs, use the gemini-pro model const model = genAI.getGenerativeModel({ - model: "gemini-pro", + model: "gemini-1.5-flash-latest", safetySettings: [ { category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, diff --git a/samples/node/file-upload.js b/samples/node/file-upload.js index 240502a6..d5162c05 100644 --- a/samples/node/file-upload.js +++ b/samples/node/file-upload.js @@ -28,9 +28,8 @@ import { GoogleAIFileManager } from "@google/generative-ai/files"; import { genAI } from "./utils/common.js"; async function run() { - // For text-only inputs, use the gemini-pro model const model = genAI.getGenerativeModel({ - model: "gemini-1.5-pro-latest", + model: "gemini-1.5-flash-latest", }); const fileManager = new GoogleAIFileManager(process.env.API_KEY); diff --git a/samples/node/simple-chat.js b/samples/node/simple-chat.js index 93df3d12..393f4a8e 100644 --- a/samples/node/simple-chat.js +++ b/samples/node/simple-chat.js @@ -18,8 +18,7 @@ import { genAI } from "./utils/common.js"; async function run() { - // For dialog language tasks (like chat), use the gemini-pro model - const model = genAI.getGenerativeModel({ model: "gemini-pro" }); + const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest"}); const chat = model.startChat(); diff --git a/samples/node/simple-config.js b/samples/node/simple-config.js index 59cae9ce..9f3f63dc 100644 --- a/samples/node/simple-config.js +++ b/samples/node/simple-config.js @@ -18,8 +18,7 @@ import { genAI } from "./utils/common.js"; async function run(options = {}) { - // For text-only inputs, use the gemini-pro model - const model = genAI.getGenerativeModel({ model: "gemini-pro", ...options }); + const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest", ...options }); const prompt = "One, two, three, "; diff --git a/samples/node/simple-text-and-images.js b/samples/node/simple-text-and-images.js index fa3af9f4..8789b391 100644 --- a/samples/node/simple-text-and-images.js +++ b/samples/node/simple-text-and-images.js @@ -18,8 +18,7 @@ import { genAI, fileToGenerativePart, streamToStdout } from "./utils/common.js"; async function run() { - // For text-and-images inputs (multimodal), use the gemini-pro-vision model - const model = genAI.getGenerativeModel({ model: "gemini-pro-vision" }); + const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest" }); const prompt = "What do you see?"; diff --git a/samples/node/simple-text.js b/samples/node/simple-text.js index 9097a741..1028fe4e 100644 --- a/samples/node/simple-text.js +++ b/samples/node/simple-text.js @@ -18,8 +18,7 @@ import { genAI } from "./utils/common.js"; async function run() { - // For text-only inputs, use the gemini-pro model - const model = genAI.getGenerativeModel({ model: "gemini-pro" }); + const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash-latest" }); const prompt = "Write a story about a magic backpack."; diff --git a/samples/web/chat.html b/samples/web/chat.html index ace3beb7..7f6987c6 100644 --- a/samples/web/chat.html +++ b/samples/web/chat.html @@ -60,7 +60,7 @@ event.preventDefault(); if (!chat) { - const model = await getGenerativeModel({ model: "gemini-pro" }); + const model = await getGenerativeModel({ model: "gemini-1.5-flash-latest" }); chat = model.startChat({ generationConfig: { maxOutputTokens: 100, diff --git a/samples/web/index.html b/samples/web/index.html index 8625d70d..b87097a5 100644 --- a/samples/web/index.html +++ b/samples/web/index.html @@ -55,7 +55,7 @@ ); const model = await getGenerativeModel({ - model: imageParts.length ? "gemini-pro-vision" : "gemini-pro", + model: "gemini-1.5-flash-latest", }); return model.generateContentStream([...imageParts, prompt]); diff --git a/samples/web/utils/shared.js b/samples/web/utils/shared.js index 522c298b..f57422b8 100644 --- a/samples/web/utils/shared.js +++ b/samples/web/utils/shared.js @@ -31,7 +31,6 @@ export async function getGenerativeModel(params) { const genAI = new GoogleGenerativeAI(API_KEY); - // For text-only inputs, use the gemini-pro model return genAI.getGenerativeModel(params); }