fix(protocol): Grok 生图 - 让 response_format 开关生效 (#692)
This commit is contained in:
1 parent
53ee5b0cbd
commit
f6003c1c88
3 files changed
+18
-1
No files matched your search
@@ -303,7 +303,7 @@ func grokImageRequestBody(input canvasGenerationInput) (grokImageRequest, string
|
||||
Model: input.Config.Model,
|
||||
Prompt: withSystemPrompt(input.Config, input.Prompt),
|
||||
N: 1,
|
||||
ResponseFormat: "url",
|
||||
ResponseFormat: grokImageResponseFormat(input.ImageCapability),
|
||||
// Grok 图片协议用 aspect_ratio 表达画布比例;同时发送 size 会被上游按 OpenAI 枚举校验并拒绝。
|
||||
AspectRatio: normalizeGrokImageAspectRatio(input.Config.Size),
|
||||
Resolution: normalizeGrokImageResolution(input.Config.Quality),
|
||||
@@ -322,6 +322,13 @@ func grokImageRequestBody(input canvasGenerationInput) (grokImageRequest, string
|
||||
return body, "/images/edits", nil
|
||||
}
|
||||
|
||||
func grokImageResponseFormat(profile *ImageCapabilityConfig) string {
|
||||
if imageParameterSupported(profile, "response_format") {
|
||||
return "b64_json"
|
||||
}
|
||||
return "url"
|
||||
}
|
||||
|
||||
// normalizeGrokImageResolution 把画布 quality(1k/2k/high…)映射为 grok2api / xAI 的 resolution。
|
||||
func normalizeGrokImageResolution(quality string) string {
|
||||
raw := strings.ToLower(strings.TrimSpace(quality))
|
||||
|
||||
Reference in new issue
Block a user