Skip to content

Commit 02e6172

Browse files
authored
fix(js/plugins/google-genai): Fix streaming aggregation of inlineData (#3794)
1 parent be12117 commit 02e6172

File tree

9 files changed

+14
-24
lines changed

9 files changed

+14
-24
lines changed

js/plugins/google-genai/src/common/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ function aggregateResponses(
491491
if (part.codeExecutionResult) {
492492
newPart.codeExecutionResult = part.codeExecutionResult;
493493
}
494+
if (part.inlineData) {
495+
newPart.inlineData = part.inlineData;
496+
}
494497
if (Object.keys(newPart).length === 0) {
495498
newPart.text = '';
496499
}

js/plugins/google-genai/src/googleai/gemini.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,6 @@ const KNOWN_GEMINI_MODELS = {
370370
'gemini-2.5-flash-image-preview': commonRef('gemini-2.5-flash-image-preview'),
371371
'gemini-2.5-flash-image': commonRef('gemini-2.5-flash-image'),
372372
'gemini-2.0-flash': commonRef('gemini-2.0-flash'),
373-
'gemini-2.0-flash-preview-image-generation': commonRef(
374-
'gemini-2.0-flash-preview-image-generation'
375-
),
376373
'gemini-2.0-flash-lite': commonRef('gemini-2.0-flash-lite'),
377374
};
378375
export type KnownGeminiModels = keyof typeof KNOWN_GEMINI_MODELS;

js/plugins/google-genai/src/googleai/imagen.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ const GENERIC_MODEL = commonRef('imagen', {
116116
});
117117

118118
const KNOWN_MODELS = {
119-
'imagen-3.0-generate-002': commonRef('imagen-3.0-generate-002'),
120119
'imagen-4.0-fast-generate-001': commonRef('imagen-4.0-fast-generate-001'),
121120
'imagen-4.0-generate-001': commonRef('imagen-4.0-generate-001'),
122121
'imagen-4.0-ultra-generate-001': commonRef('imagen-4.0-ultra-generate-001'),

js/plugins/google-genai/src/vertexai/veo.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ const KNOWN_MODELS = {
150150
'veo-2.0-generate-001': commonRef('veo-2.0-generate-001'),
151151
'veo-3.0-generate-001': commonRef('veo-3.0-generate-001'),
152152
'veo-3.0-fast-generate-001': commonRef('veo-3.0-fast-generate-001'),
153-
'veo-3.0-generate-preview': commonRef('veo-3.0-generate-preview'),
154-
'veo-3.0-fast-generate-preview': commonRef('veo-3.0-fast-generate-preview'),
155153
'veo-3.1-fast-generate-001': commonRef('veo-3.1-fast-generate-001'),
156154
'veo-3.1-fast-generate-preview': commonRef('veo-3.1-fast-generate-preview'),
157155
'veo-3.1-generate-001': commonRef('veo-3.1-generate-001'),

js/plugins/vertexai/src/modelgarden/v2/anthropic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ function commonRef(
8383
export const GENERIC_MODEL = commonRef('anthropic');
8484

8585
export const KNOWN_MODELS = {
86+
'claude-haiku-4-5@20251001': commonRef('claude-haiku-4-5@20251001'),
8687
'claude-sonnet-4-5@20250929': commonRef('claude-sonnet-4-5@20250929'),
8788
'claude-sonnet-4@20250514': commonRef('claude-sonnet-4@20250514'),
88-
'claude-3-7-sonnet@20250219': commonRef('claude-3-7-sonnet@20250219'),
8989
'claude-opus-4-1@20250805': commonRef('claude-opus-4-1@20250805'),
9090
'claude-opus-4@20250514': commonRef('claude-opus-4@20250514'),
9191
'claude-3-5-haiku@20241022': commonRef('claude-3-5-haiku@20241022'),

js/plugins/vertexai/src/modelgarden/v2/mistral.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const KNOWN_MODELS = {
9898
'mistral-large-2411': commonRef('mistral-large-2411'),
9999
'mistral-ocr-2505': commonRef('mistral-ocr-2505'),
100100
'mistral-small-2503': commonRef('mistral-small-2503'),
101+
'codestral-2': commonRef('codestral-2'),
101102
'codestral-2501': commonRef('codestral-2501'),
102103
};
103104
export type KnownModels = keyof typeof KNOWN_MODELS;

js/pnpm-lock.yaml

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/testapps/flow-simple-ai/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"@genkit-ai/evaluator": "workspace:*",
2020
"@genkit-ai/firebase": "workspace:*",
2121
"@genkit-ai/google-cloud": "workspace:*",
22-
"@genkit-ai/googleai": "workspace:*",
23-
"@genkit-ai/vertexai": "workspace:*",
22+
"@genkit-ai/google-genai": "workspace:*",
2423
"@google/generative-ai": "^0.15.0",
2524
"@opentelemetry/sdk-trace-base": "~1.25.0",
2625
"body-parser": "^1.20.3",

js/testapps/flow-simple-ai/src/index.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
import { GenkitMetric, genkitEval } from '@genkit-ai/evaluator';
1818
import { defineFirestoreRetriever } from '@genkit-ai/firebase';
1919
import { enableGoogleCloudTelemetry } from '@genkit-ai/google-cloud';
20-
import { googleAI } from '@genkit-ai/googleai';
21-
import { vertexAI } from '@genkit-ai/vertexai';
20+
import { googleAI, vertexAI } from '@genkit-ai/google-genai';
2221
import { GoogleAIFileManager } from '@google/generative-ai/server';
2322
import { AlwaysOnSampler } from '@opentelemetry/sdk-trace-base';
2423
import { initializeApp } from 'firebase-admin/app';
@@ -255,17 +254,14 @@ export const jokeWithToolsFlow = ai.defineFlow(
255254
{
256255
name: 'jokeWithToolsFlow',
257256
inputSchema: z.object({
258-
modelName: z.enum([
259-
googleAI.model('gemini-2.5-flash').name,
260-
googleAI.model('gemini-2.5-pro').name,
261-
]),
257+
modelName: z.enum(['gemini-2.5-flash', 'gemini-2.5-pro']),
262258
subject: z.string(),
263259
}),
264260
outputSchema: z.object({ model: z.string(), joke: z.string() }),
265261
},
266262
async (input) => {
267263
const llmResponse = await ai.generate({
268-
model: input.modelName as string,
264+
model: googleAI.model(input.modelName as string),
269265
tools,
270266
output: { schema: z.object({ joke: z.string() }) },
271267
prompt: `Tell a joke about ${input.subject}.`,
@@ -282,14 +278,14 @@ export const jokeWithOutputFlow = ai.defineFlow(
282278
{
283279
name: 'jokeWithOutputFlow',
284280
inputSchema: z.object({
285-
modelName: z.enum([googleAI.model('gemini-2.5-flash').name]),
281+
modelName: z.enum(['gemini-2.5-flash']),
286282
subject: z.string(),
287283
}),
288284
outputSchema,
289285
},
290286
async (input, { sendChunk }) => {
291287
const llmResponse = await ai.generate({
292-
model: input.modelName,
288+
model: googleAI.model(input.modelName),
293289
output: {
294290
format: 'json',
295291
schema: outputSchema,
@@ -914,7 +910,7 @@ ai.defineFlow(
914910

915911
ai.defineFlow('geminiImages', async (_, { sendChunk }) => {
916912
const { response, stream } = ai.generateStream({
917-
model: googleAI.model('gemini-2.0-flash-preview-image-generation'),
913+
model: googleAI.model('gemini-2.5-flash-image'),
918914
prompt: `generate an image of a banana riding a bicycle`,
919915
config: {
920916
responseModalities: ['TEXT', 'IMAGE'],

0 commit comments

Comments
 (0)