Repository navigation
feat: gemini imagen quality value - #1983
Conversation
WalkthroughAdds ImageSize to GeminiImageParameters and updates Gemini adaptor logic to map more image size strings to aspect ratios and derive Parameters.ImageSize from request.Quality when provided. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant Adaptor as Gemini Adaptor
participant Gemini as Gemini API
Client->>Adaptor: Submit image generation request (size, quality)
rect rgba(200,230,255,0.3)
note right of Adaptor: Size → Aspect Ratio
Adaptor->>Adaptor: Map size string\n- 256x256/512x512/1024x1024 → 1:1\n- 1536x1024 → 3:2\n- 1024x1536 → 2:3
end
rect rgba(200,255,220,0.3)
note right of Adaptor: Quality → ImageSize (if provided)
alt quality in ["hd","high","2K"]
Adaptor->>Adaptor: Parameters.ImageSize = "2K"
else other/non-empty quality
Adaptor->>Adaptor: Parameters.ImageSize = "1K"
end
end
Adaptor->>Gemini: Send request with Parameters{aspectRatio, imageSize?}
Gemini-->>Adaptor: Response
Adaptor-->>Client: Result
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
relay/channel/gemini/adaptor.go (1)
98-118: Consider simplifying the quality mapping logic.The switch statement can be streamlined since multiple cases and the default all map to "1K":
Apply this diff to simplify:
- if request.Quality != "" { - imageSize := "1K" // default - switch request.Quality { - case "hd", "high": - imageSize = "2K" - case "2K": - imageSize = "2K" - case "standard", "medium", "low", "auto", "1K": - imageSize = "1K" - default: - // unknown quality value, default to 1K - imageSize = "1K" - } - geminiRequest.Parameters.ImageSize = imageSize - } + if request.Quality != "" { + imageSize := "1K" // default for standard, medium, low, auto, 1K, and unknown values + if request.Quality == "hd" || request.Quality == "high" || request.Quality == "2K" { + imageSize = "2K" + } + geminiRequest.Parameters.ImageSize = imageSize + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
dto/gemini.go(1 hunks)relay/channel/gemini/adaptor.go(2 hunks)
🔇 Additional comments (2)
dto/gemini.go (1)
332-332: LGTM!The
ImageSizefield addition is correctly structured with appropriate JSON tags and follows the existing conventions in the struct.relay/channel/gemini/adaptor.go (1)
70-75: LGTM!The additional image size mappings are correct:
- 256x256 and 512x512 appropriately map to 1:1 aspect ratio
- 1536x1024 correctly maps to 3:2
- 1024x1536 correctly maps to 2:3
feat: gemini imagen quality value
feat: gemini imagen quality value
feat: gemini imagen quality value
imageSizeparameter when requesting gemini imagen models to control the size of the generated images (for openai endpoint, this value is mapped toquality)https://ai.google.dev/gemini-api/docs/imagen
https://platform.openai.com/docs/api-reference/images/create
Summary by CodeRabbit