mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 08:30:39 +00:00
Gemini nano banana pro updated (#2012)
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test (20.x) (push) Has been cancelled
test / test (22.x) (push) Has been cancelled
test / backend (node env, api-test) (22.x) (push) Has been cancelled
test / puterjs (browser env, playwright) (22.x) (push) Has been cancelled
test / puterjs (node env, vitest) (22.x) (push) Has been cancelled
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test (20.x) (push) Has been cancelled
test / test (22.x) (push) Has been cancelled
test / backend (node env, api-test) (22.x) (push) Has been cancelled
test / puterjs (browser env, playwright) (22.x) (push) Has been cancelled
test / puterjs (node env, vitest) (22.x) (push) Has been cancelled
* Update AI.js * Update GeminiImageGenerationService.js * Update cost map * Gemini to OpenAI SDK refactor (#2014) * WIP Gemini OpenAI refactor * refactor: gemini open ai service + geminiCostMap * Gemini Service fixes * Cleaning up old Gemini cruft --------- Co-authored-by: Daniel Salazar <daniel.salazar@puter.com> --------- Co-authored-by: Nihhaar0002 <msnrk2006@gmail.com> Co-authored-by: Daniel Salazar <daniel.salazar@puter.com>
This commit is contained in:
@@ -42,6 +42,9 @@ class GeminiImageGenerationService extends BaseService {
|
||||
'gemini-2.5-flash-image-preview': {
|
||||
'1024x1024': 0.039,
|
||||
},
|
||||
'gemini-3-pro-image-preview': {
|
||||
'1024x1024': 0.156,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -192,9 +195,10 @@ class GeminiImageGenerationService extends BaseService {
|
||||
}
|
||||
|
||||
const response = await this.genAI.models.generateContent({
|
||||
model: 'gemini-2.5-flash-image-preview',
|
||||
contents: contents,
|
||||
model,
|
||||
contents,
|
||||
});
|
||||
|
||||
// Metering usage tracking
|
||||
// Gemini usage: always 1 image, resolution, cost, model
|
||||
this.meteringService.incrementUsage(actor, usageType, 1);
|
||||
@@ -221,10 +225,14 @@ class GeminiImageGenerationService extends BaseService {
|
||||
* @returns {Array<Object>} Array of valid ratio objects
|
||||
* @private
|
||||
*/
|
||||
_getValidRatios (model) {
|
||||
if ( model === 'gemini-2.5-flash-image-preview' ) {
|
||||
_getValidRatios(model) {
|
||||
if (
|
||||
model === 'gemini-2.5-flash-image-preview' ||
|
||||
model === 'gemini-3-pro-image-preview'
|
||||
) {
|
||||
return [this.constructor.RATIO_SQUARE];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
_validate_ratio (ratio, model) {
|
||||
|
||||
@@ -24,4 +24,5 @@ export const GEMINI_COST_MAP = {
|
||||
'gemini:gemini-3-pro-preview:promptTokenCount': 25,
|
||||
'gemini:gemini-3-pro-preview:candidatesTokenCount': 100,
|
||||
'gemini:gemini-2.5-flash-image-preview:1024x1024': 3_900_000,
|
||||
'gemini:gemini-3-pro-image-preview:1024x1024': 15_600_000
|
||||
};
|
||||
|
||||
@@ -1001,6 +1001,10 @@ class AI {
|
||||
options.model = 'gemini-2.5-flash-image-preview';
|
||||
}
|
||||
|
||||
if (options.model === "nano-banana-pro") {
|
||||
options.model = "gemini-3-pro-image-preview";
|
||||
}
|
||||
|
||||
const driverHint = typeof options.driver === 'string' ? options.driver : undefined;
|
||||
const providerRaw = typeof options.provider === 'string'
|
||||
? options.provider
|
||||
@@ -1019,7 +1023,7 @@ class AI {
|
||||
AIService = 'gemini-image-generation';
|
||||
} else if ( providerHint === 'together' || providerHint === 'together-ai' ) {
|
||||
AIService = 'together-image-generation';
|
||||
} else if ( options.model === 'gemini-2.5-flash-image-preview' ) {
|
||||
} else if (options.model === 'gemini-2.5-flash-image-preview' || options.model === "gemini-3-pro-image-preview" ) {
|
||||
AIService = 'gemini-image-generation';
|
||||
} else if ( looksLikeTogetherModel ) {
|
||||
AIService = 'together-image-generation';
|
||||
|
||||
Reference in New Issue
Block a user