feat: gemini imagen quality value
This commit is contained in:
@@ -329,6 +329,7 @@ type GeminiImageParameters struct {
|
|||||||
SampleCount int `json:"sampleCount,omitempty"`
|
SampleCount int `json:"sampleCount,omitempty"`
|
||||||
AspectRatio string `json:"aspectRatio,omitempty"`
|
AspectRatio string `json:"aspectRatio,omitempty"`
|
||||||
PersonGeneration string `json:"personGeneration,omitempty"`
|
PersonGeneration string `json:"personGeneration,omitempty"`
|
||||||
|
ImageSize string `json:"imageSize,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GeminiImageResponse struct {
|
type GeminiImageResponse struct {
|
||||||
|
|||||||
@@ -67,8 +67,12 @@ func (a *Adaptor) ConvertImageRequest(c *gin.Context, info *relaycommon.RelayInf
|
|||||||
aspectRatio = size
|
aspectRatio = size
|
||||||
} else {
|
} else {
|
||||||
switch size {
|
switch size {
|
||||||
case "1024x1024":
|
case "256x256", "512x512", "1024x1024":
|
||||||
aspectRatio = "1:1"
|
aspectRatio = "1:1"
|
||||||
|
case "1536x1024":
|
||||||
|
aspectRatio = "3:2"
|
||||||
|
case "1024x1536":
|
||||||
|
aspectRatio = "2:3"
|
||||||
case "1024x1792":
|
case "1024x1792":
|
||||||
aspectRatio = "9:16"
|
aspectRatio = "9:16"
|
||||||
case "1792x1024":
|
case "1792x1024":
|
||||||
@@ -91,6 +95,28 @@ func (a *Adaptor) ConvertImageRequest(c *gin.Context, info *relaycommon.RelayInf
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set imageSize when quality parameter is specified
|
||||||
|
// Map quality parameter to imageSize (only supported by Standard and Ultra models)
|
||||||
|
// quality values: auto, high, medium, low (for gpt-image-1), hd, standard (for dall-e-3)
|
||||||
|
// imageSize values: 1K (default), 2K
|
||||||
|
// https://ai.google.dev/gemini-api/docs/imagen
|
||||||
|
// https://platform.openai.com/docs/api-reference/images/create
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
return geminiRequest, nil
|
return geminiRequest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user