Skip to content

Commit b832886

Browse files
committed
replicate changes for nano banana for google as well
1 parent 1713d57 commit b832886

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/providers/google/chatComplete.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ const transformGenerationConfig = (params: Params) => {
7878
thinkingConfig['thinking_budget'] = params.thinking.budget_tokens;
7979
generationConfig['thinking_config'] = thinkingConfig;
8080
}
81+
if (params.modalities) {
82+
generationConfig['responseModalities'] = params.modalities.map((modality) =>
83+
modality.toUpperCase()
84+
);
85+
}
8186
return generationConfig;
8287
};
8388

@@ -425,6 +430,10 @@ export const GoogleChatCompleteConfig: ProviderConfig = {
425430
param: 'generationConfig',
426431
transform: (params: Params) => transformGenerationConfig(params),
427432
},
433+
modalities: {
434+
param: 'generationConfig',
435+
transform: (params: Params) => transformGenerationConfig(params),
436+
},
428437
};
429438

430439
export interface GoogleErrorResponse {
@@ -447,6 +456,10 @@ interface GoogleResponseCandidate {
447456
text?: string;
448457
thought?: string; // for models like gemini-2.0-flash-thinking-exp refer: https://ai.google.dev/gemini-api/docs/thinking-mode#streaming_model_thinking
449458
functionCall?: GoogleGenerateFunctionCall;
459+
inlineData?: {
460+
mimeType: string;
461+
data: string;
462+
};
450463
}[];
451464
};
452465
logprobsResult?: {
@@ -560,6 +573,13 @@ export const GoogleChatCompleteResponseTransform: (
560573
content = part.text;
561574
contentBlocks.push({ type: 'text', text: part.text });
562575
}
576+
} else if (part.inlineData) {
577+
contentBlocks.push({
578+
type: 'image_url',
579+
image_url: {
580+
url: `data:${part.inlineData.mimeType};base64,${part.inlineData.data}`,
581+
},
582+
});
563583
}
564584
}
565585

0 commit comments

Comments
 (0)