Skip to content

Commit

Permalink
Update model names to use gemini-1.5-flash-latest (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 authored May 20, 2024
1 parent cc25b72 commit e308643
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 49 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions packages/main/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/test-integration/node/count-tokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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: [
Expand Down
10 changes: 5 additions & 5 deletions packages/main/test-integration/node/generate-content.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions packages/main/test-integration/node/start-chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions packages/main/test-integration/web/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions samples/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions samples/node/advanced-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
3 changes: 1 addition & 2 deletions samples/node/advanced-function-calling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
);

Expand Down
3 changes: 1 addition & 2 deletions samples/node/advanced-text-and-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
3 changes: 1 addition & 2 deletions samples/node/advanced-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions samples/node/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions samples/node/simple-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 1 addition & 2 deletions samples/node/simple-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, ";

Expand Down
3 changes: 1 addition & 2 deletions samples/node/simple-text-and-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?";

Expand Down
3 changes: 1 addition & 2 deletions samples/node/simple-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.";

Expand Down
2 changes: 1 addition & 1 deletion samples/web/chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion samples/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
1 change: 0 additions & 1 deletion samples/web/utils/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit e308643

Please sign in to comment.