File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -116,9 +116,15 @@ class GeminiGenerationConfig(BaseModel):
116116 topP : float | None = Field (None , ge = 0.0 , le = 1.0 )
117117
118118
119+ class GeminiImageOutputOptions (BaseModel ):
120+ mimeType : str = Field ("image/png" )
121+ compressionQuality : int | None = Field (None )
122+
123+
119124class GeminiImageConfig (BaseModel ):
120125 aspectRatio : str | None = Field (None )
121126 imageSize : str | None = Field (None )
127+ imageOutputOptions : GeminiImageOutputOptions = Field (default_factory = GeminiImageOutputOptions )
122128
123129
124130class GeminiImageGenerationConfig (GeminiGenerationConfig ):
Original file line number Diff line number Diff line change @@ -634,7 +634,7 @@ async def execute(
634634
635635 if not aspect_ratio :
636636 aspect_ratio = "auto" # for backward compatability with old workflows; to-do remove this in December
637- image_config = GeminiImageConfig (aspectRatio = aspect_ratio )
637+ image_config = GeminiImageConfig () if aspect_ratio == "auto" else GeminiImageConfig ( aspectRatio = aspect_ratio )
638638
639639 if images is not None :
640640 parts .extend (await create_image_parts (cls , images ))
@@ -654,7 +654,7 @@ async def execute(
654654 ],
655655 generationConfig = GeminiImageGenerationConfig (
656656 responseModalities = (["IMAGE" ] if response_modalities == "IMAGE" else ["TEXT" , "IMAGE" ]),
657- imageConfig = None if aspect_ratio == "auto" else image_config ,
657+ imageConfig = image_config ,
658658 ),
659659 systemInstruction = gemini_system_prompt ,
660660 ),
You can’t perform that action at this time.
0 commit comments