From 933fa5e615b6396111a81b7145ba9e7d6bd0862f Mon Sep 17 00:00:00 2001 From: Shruti Padamata Date: Mon, 16 Jun 2025 12:12:58 -0700 Subject: [PATCH 1/4] fix: Limits on common model config --- js/ai/src/model.ts | 2 +- js/plugins/googleai/src/gemini.ts | 126 ++++++++++++++++++++++++++++-- js/plugins/googleai/src/index.ts | 6 +- 3 files changed, 125 insertions(+), 9 deletions(-) diff --git a/js/ai/src/model.ts b/js/ai/src/model.ts index e450c9b9d4..a1c212d768 100644 --- a/js/ai/src/model.ts +++ b/js/ai/src/model.ts @@ -235,7 +235,7 @@ export const GenerationCommonConfigSchema = z .optional(), stopSequences: z .array(z.string()) - .length(5) + .max(5) .describe( 'Set of character sequences (up to 5) that will stop output generation.' ) diff --git a/js/plugins/googleai/src/gemini.ts b/js/plugins/googleai/src/gemini.ts index 46d239f21b..4c2ec4e0e5 100644 --- a/js/plugins/googleai/src/gemini.ts +++ b/js/plugins/googleai/src/gemini.ts @@ -45,6 +45,7 @@ import { type JSONSchema, } from 'genkit'; import { + GenerationCommonConfigDescriptions, GenerationCommonConfigSchema, getBasicUsageStats, modelRef, @@ -140,6 +141,23 @@ const VoiceConfigSchema = z .passthrough(); export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({ + temperature: z + .number() + .min(0) + .max(2) + .describe( + GenerationCommonConfigDescriptions.temperature + + ' The default value is 1.0.' + ) + .optional(), + topP: z + .number() + .min(0) + .max(1) + .describe( + GenerationCommonConfigDescriptions.topP + ' The default value is 0.95.' + ) + .optional(), apiKey: z .string() .describe('Overrides the plugin-configured API key, if specified.') @@ -192,6 +210,18 @@ export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({ }).passthrough(); export type GeminiConfig = z.infer; +export const GeminiGemmaConfigSchema = GeminiConfigSchema.extend({ + temperature: z + .number() + .min(0.0) + .max(1.0) + .describe( + GenerationCommonConfigDescriptions.temperature + + ' The default value is 1.0.' + ) + .optional(), +}).passthrough(); + export const GeminiTtsConfigSchema = GeminiConfigSchema.extend({ speechConfig: z .object({ @@ -452,7 +482,92 @@ export const gemini25ProPreviewTts = modelRef({ configSchema: GeminiTtsConfigSchema, }); -export const SUPPORTED_V15_MODELS = { +export const gemma312bit = modelRef({ + name: 'googleai/gemma-3-12b-it', + info: { + label: 'Google AI - Gemma 3 12B', + versions: [], + supports: { + multiturn: true, + media: true, + tools: true, + toolChoice: true, + systemRole: true, + constrained: 'no-tools', + }, + }, + configSchema: GeminiGemmaConfigSchema, +}); + +export const gemma31bit = modelRef({ + name: 'googleai/gemma-3-1b-it', + info: { + label: 'Google AI - Gemma 3 1B', + versions: [], + supports: { + multiturn: true, + media: true, + tools: true, + toolChoice: true, + systemRole: true, + constrained: 'no-tools', + }, + }, + configSchema: GeminiGemmaConfigSchema, +}); + +export const gemma327bit = modelRef({ + name: 'googleai/gemma-3-27b-it', + info: { + label: 'Google AI - Gemma 3 27B', + versions: [], + supports: { + multiturn: true, + media: true, + tools: true, + toolChoice: true, + systemRole: true, + constrained: 'no-tools', + }, + }, + configSchema: GeminiGemmaConfigSchema, +}); + +export const gemma34bit = modelRef({ + name: 'googleai/gemma-3-4b-it', + info: { + label: 'Google AI - Gemma 3 4B', + versions: [], + supports: { + multiturn: true, + media: true, + tools: true, + toolChoice: true, + systemRole: true, + constrained: 'no-tools', + }, + }, + configSchema: GeminiGemmaConfigSchema, +}); + +export const gemma3ne4bit = modelRef({ + name: 'googleai/gemma-3n-e4b-it', + info: { + label: 'Google AI - Gemma 3n E4B', + versions: [], + supports: { + multiturn: true, + media: true, + tools: true, + toolChoice: true, + systemRole: true, + constrained: 'no-tools', + }, + }, + configSchema: GeminiGemmaConfigSchema, +}); + +export const SUPPORTED_GEMINI_MODELS = { 'gemini-1.5-pro': gemini15Pro, 'gemini-1.5-flash': gemini15Flash, 'gemini-1.5-flash-8b': gemini15Flash8b, @@ -465,6 +580,11 @@ export const SUPPORTED_V15_MODELS = { 'gemini-2.5-pro-preview-tts': gemini25ProPreviewTts, 'gemini-2.5-flash-preview-04-17': gemini25FlashPreview0417, 'gemini-2.5-flash-preview-tts': gemini25FlashPreviewTts, + 'gemma-3-12b-it': gemma312bit, + 'gemma-3-1b-it': gemma31bit, + 'gemma-3-27b-it': gemma327bit, + 'gemma-3-4b-it': gemma34bit, + 'gemma-3n-e4b-it': gemma3ne4bit, }; export const GENERIC_GEMINI_MODEL = modelRef({ @@ -483,10 +603,6 @@ export const GENERIC_GEMINI_MODEL = modelRef({ }, }); -export const SUPPORTED_GEMINI_MODELS = { - ...SUPPORTED_V15_MODELS, -} as const; - function longestMatchingPrefix(version: string, potentialMatches: string[]) { return potentialMatches .filter((p) => version.startsWith(p)) diff --git a/js/plugins/googleai/src/index.ts b/js/plugins/googleai/src/index.ts index 771b549295..c360b98516 100644 --- a/js/plugins/googleai/src/index.ts +++ b/js/plugins/googleai/src/index.ts @@ -39,7 +39,7 @@ import { } from './embedder.js'; import { GeminiConfigSchema, - SUPPORTED_V15_MODELS, + SUPPORTED_GEMINI_MODELS, defineGoogleAIModel, gemini, gemini10Pro, @@ -108,7 +108,7 @@ async function initializer(ai: Genkit, options?: PluginOptions) { } if (apiVersions.includes('v1beta')) { - Object.keys(SUPPORTED_V15_MODELS).forEach((name) => + Object.keys(SUPPORTED_GEMINI_MODELS).forEach((name) => defineGoogleAIModel({ ai, name, @@ -120,7 +120,7 @@ async function initializer(ai: Genkit, options?: PluginOptions) { ); } if (apiVersions.includes('v1')) { - Object.keys(SUPPORTED_V15_MODELS).forEach((name) => + Object.keys(SUPPORTED_GEMINI_MODELS).forEach((name) => defineGoogleAIModel({ ai, name, From 1e81325a15af89213b2b8d34b95ce8ee002d8a39 Mon Sep 17 00:00:00 2001 From: Julio <38758281+Julioevm@users.noreply.github.com> Date: Fri, 20 Jun 2025 09:37:10 +0200 Subject: [PATCH 2/4] feat: Update Gemini models --- js/plugins/googleai/src/gemini.ts | 139 +++++++++--------------------- 1 file changed, 39 insertions(+), 100 deletions(-) diff --git a/js/plugins/googleai/src/gemini.ts b/js/plugins/googleai/src/gemini.ts index 4c2ec4e0e5..353ed8377e 100644 --- a/js/plugins/googleai/src/gemini.ts +++ b/js/plugins/googleai/src/gemini.ts @@ -45,7 +45,6 @@ import { type JSONSchema, } from 'genkit'; import { - GenerationCommonConfigDescriptions, GenerationCommonConfigSchema, getBasicUsageStats, modelRef, @@ -141,23 +140,6 @@ const VoiceConfigSchema = z .passthrough(); export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({ - temperature: z - .number() - .min(0) - .max(2) - .describe( - GenerationCommonConfigDescriptions.temperature + - ' The default value is 1.0.' - ) - .optional(), - topP: z - .number() - .min(0) - .max(1) - .describe( - GenerationCommonConfigDescriptions.topP + ' The default value is 0.95.' - ) - .optional(), apiKey: z .string() .describe('Overrides the plugin-configured API key, if specified.') @@ -210,18 +192,6 @@ export const GeminiConfigSchema = GenerationCommonConfigSchema.extend({ }).passthrough(); export type GeminiConfig = z.infer; -export const GeminiGemmaConfigSchema = GeminiConfigSchema.extend({ - temperature: z - .number() - .min(0.0) - .max(1.0) - .describe( - GenerationCommonConfigDescriptions.temperature + - ' The default value is 1.0.' - ) - .optional(), -}).passthrough(); - export const GeminiTtsConfigSchema = GeminiConfigSchema.extend({ speechConfig: z .object({ @@ -414,27 +384,10 @@ export const gemini25FlashPreview0417 = modelRef({ configSchema: GeminiConfigSchema, }); -export const gemini25FlashPreviewTts = modelRef({ - name: 'googleai/gemini-2.5-flash-preview-tts', +export const gemini25FlashLitePreview0617 = modelRef({ + name: 'googleai/gemini-2.5-flash-lite-preview-06-17', info: { - label: 'Google AI - Gemini 2.5 Flash Preview TTS', - versions: [], - supports: { - multiturn: false, - media: false, - tools: false, - toolChoice: false, - systemRole: false, - constrained: 'no-tools', - }, - }, - configSchema: GeminiTtsConfigSchema, -}); - -export const gemini25ProExp0325 = modelRef({ - name: 'googleai/gemini-2.5-pro-exp-03-25', - info: { - label: 'Google AI - Gemini 2.5 Pro Exp 03-25', + label: 'Google AI - Gemini 2.5 Flash Lite Preview 06-17', versions: [], supports: { multiturn: true, @@ -448,10 +401,10 @@ export const gemini25ProExp0325 = modelRef({ configSchema: GeminiConfigSchema, }); -export const gemini25ProPreview0325 = modelRef({ - name: 'googleai/gemini-2.5-pro-preview-03-25', +export const gemini25Flash = modelRef({ + name: 'googleai/gemini-2.5-flash', info: { - label: 'Google AI - Gemini 2.5 Pro Preview 03-25', + label: 'Google AI - Gemini 2.5 Flash', versions: [], supports: { multiturn: true, @@ -465,10 +418,10 @@ export const gemini25ProPreview0325 = modelRef({ configSchema: GeminiConfigSchema, }); -export const gemini25ProPreviewTts = modelRef({ - name: 'googleai/gemini-2.5-pro-preview-tts', +export const gemini25FlashPreviewTts = modelRef({ + name: 'googleai/gemini-2.5-flash-preview-tts', info: { - label: 'Google AI - Gemini 2.5 Pro Preview TTS', + label: 'Google AI - Gemini 2.5 Flash Preview TTS', versions: [], supports: { multiturn: false, @@ -482,27 +435,10 @@ export const gemini25ProPreviewTts = modelRef({ configSchema: GeminiTtsConfigSchema, }); -export const gemma312bit = modelRef({ - name: 'googleai/gemma-3-12b-it', - info: { - label: 'Google AI - Gemma 3 12B', - versions: [], - supports: { - multiturn: true, - media: true, - tools: true, - toolChoice: true, - systemRole: true, - constrained: 'no-tools', - }, - }, - configSchema: GeminiGemmaConfigSchema, -}); - -export const gemma31bit = modelRef({ - name: 'googleai/gemma-3-1b-it', +export const gemini25ProExp0325 = modelRef({ + name: 'googleai/gemini-2.5-pro-exp-03-25', info: { - label: 'Google AI - Gemma 3 1B', + label: 'Google AI - Gemini 2.5 Pro Exp 03-25', versions: [], supports: { multiturn: true, @@ -513,13 +449,13 @@ export const gemma31bit = modelRef({ constrained: 'no-tools', }, }, - configSchema: GeminiGemmaConfigSchema, + configSchema: GeminiConfigSchema, }); -export const gemma327bit = modelRef({ - name: 'googleai/gemma-3-27b-it', +export const gemini25ProPreview0506 = modelRef({ + name: 'googleai/gemini-2.5-pro-preview-05-06', info: { - label: 'Google AI - Gemma 3 27B', + label: 'Google AI - Gemini 2.5 Pro Preview 05-06', versions: [], supports: { multiturn: true, @@ -530,13 +466,13 @@ export const gemma327bit = modelRef({ constrained: 'no-tools', }, }, - configSchema: GeminiGemmaConfigSchema, + configSchema: GeminiConfigSchema, }); -export const gemma34bit = modelRef({ - name: 'googleai/gemma-3-4b-it', +export const gemini25Pro = modelRef({ + name: 'googleai/gemini-2.5-pro', info: { - label: 'Google AI - Gemma 3 4B', + label: 'Google AI - Gemini 2.5 Pro', versions: [], supports: { multiturn: true, @@ -547,27 +483,27 @@ export const gemma34bit = modelRef({ constrained: 'no-tools', }, }, - configSchema: GeminiGemmaConfigSchema, + configSchema: GeminiConfigSchema, }); -export const gemma3ne4bit = modelRef({ - name: 'googleai/gemma-3n-e4b-it', +export const gemini25ProPreviewTts = modelRef({ + name: 'googleai/gemini-2.5-pro-preview-tts', info: { - label: 'Google AI - Gemma 3n E4B', + label: 'Google AI - Gemini 2.5 Pro Preview TTS', versions: [], supports: { - multiturn: true, - media: true, - tools: true, - toolChoice: true, - systemRole: true, + multiturn: false, + media: false, + tools: false, + toolChoice: false, + systemRole: false, constrained: 'no-tools', }, }, - configSchema: GeminiGemmaConfigSchema, + configSchema: GeminiTtsConfigSchema, }); -export const SUPPORTED_GEMINI_MODELS = { +export const SUPPORTED_V15_MODELS = { 'gemini-1.5-pro': gemini15Pro, 'gemini-1.5-flash': gemini15Flash, 'gemini-1.5-flash-8b': gemini15Flash8b, @@ -575,16 +511,15 @@ export const SUPPORTED_GEMINI_MODELS = { 'gemini-2.0-flash': gemini20Flash, 'gemini-2.0-flash-lite': gemini20FlashLite, 'gemini-2.0-flash-exp': gemini20FlashExp, + 'gemini-2.5-pro': gemini25Pro, 'gemini-2.5-pro-exp-03-25': gemini25ProExp0325, 'gemini-2.5-pro-preview-03-25': gemini25ProPreview0325, + 'gemini-2.5-pro-preview-05-06': gemini25ProPreview0325, 'gemini-2.5-pro-preview-tts': gemini25ProPreviewTts, + 'gemini-2.5-flash': gemini25Flash, 'gemini-2.5-flash-preview-04-17': gemini25FlashPreview0417, + 'gemini-2.5-flash-lite-preview-06-17': gemini25FlashLitePreview0617, 'gemini-2.5-flash-preview-tts': gemini25FlashPreviewTts, - 'gemma-3-12b-it': gemma312bit, - 'gemma-3-1b-it': gemma31bit, - 'gemma-3-27b-it': gemma327bit, - 'gemma-3-4b-it': gemma34bit, - 'gemma-3n-e4b-it': gemma3ne4bit, }; export const GENERIC_GEMINI_MODEL = modelRef({ @@ -603,6 +538,10 @@ export const GENERIC_GEMINI_MODEL = modelRef({ }, }); +export const SUPPORTED_GEMINI_MODELS = { + ...SUPPORTED_V15_MODELS, +} as const; + function longestMatchingPrefix(version: string, potentialMatches: string[]) { return potentialMatches .filter((p) => version.startsWith(p)) From 2ac07641e337aaee7564953deafc72c9746d8ab4 Mon Sep 17 00:00:00 2001 From: Julio <38758281+Julioevm@users.noreply.github.com> Date: Fri, 20 Jun 2025 09:47:39 +0200 Subject: [PATCH 3/4] fix: Add missing imports. --- js/plugins/googleai/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/plugins/googleai/src/index.ts b/js/plugins/googleai/src/index.ts index c360b98516..9cb92e5093 100644 --- a/js/plugins/googleai/src/index.ts +++ b/js/plugins/googleai/src/index.ts @@ -40,6 +40,7 @@ import { import { GeminiConfigSchema, SUPPORTED_GEMINI_MODELS, + SUPPORTED_V15_MODELS, defineGoogleAIModel, gemini, gemini10Pro, @@ -50,7 +51,10 @@ import { gemini20FlashExp, gemini20FlashLite, gemini20ProExp0205, + gemini25Flash, gemini25FlashPreview0417, + gemini25FlashLitePreview, + gemini25Pro, gemini25ProExp0325, gemini25ProPreview0325, type GeminiConfig, From d52e11cf3868702c6e8d28fff7bcc1de1aebab02 Mon Sep 17 00:00:00 2001 From: Julio <38758281+Julioevm@users.noreply.github.com> Date: Fri, 20 Jun 2025 09:59:42 +0200 Subject: [PATCH 4/4] fix: Fix model import names. --- js/plugins/googleai/src/index.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/plugins/googleai/src/index.ts b/js/plugins/googleai/src/index.ts index 9cb92e5093..f95932a110 100644 --- a/js/plugins/googleai/src/index.ts +++ b/js/plugins/googleai/src/index.ts @@ -40,7 +40,6 @@ import { import { GeminiConfigSchema, SUPPORTED_GEMINI_MODELS, - SUPPORTED_V15_MODELS, defineGoogleAIModel, gemini, gemini10Pro, @@ -53,10 +52,10 @@ import { gemini20ProExp0205, gemini25Flash, gemini25FlashPreview0417, - gemini25FlashLitePreview, + gemini25FlashLitePreview0617, gemini25Pro, gemini25ProExp0325, - gemini25ProPreview0325, + gemini25ProPreview0506, type GeminiConfig, type GeminiVersionString, } from './gemini.js'; @@ -72,8 +71,11 @@ export { gemini20FlashLite, gemini20ProExp0205, gemini25FlashPreview0417, + gemini25Flash, + gemini25FlashLitePreview0617, gemini25ProExp0325, - gemini25ProPreview0325, + gemini25ProPreview0506, + gemini25Pro, textEmbedding004, textEmbeddingGecko001, type GeminiConfig,