grok修复

This commit is contained in:
2026-07-03 23:33:04 +08:00
parent c6a8ca440a
commit 34e69adefc
2 changed files with 9 additions and 2 deletions
@@ -458,7 +458,7 @@ func (h *UserGenerationHandler) catalogEntries(c *gin.Context) ([]gin.H, error)
"type": "video",
"ratios": []string{"2:3", "3:2", "1:1", "9:16", "16:9"},
"resolutions": []string{"720p"},
"durations": []string{"6s", "10s", "15s"},
"durations": []string{"6s", "10s"},
"max_reference_images": 6,
"reference_mode": "asset",
"description": "Grok Imagine video (文/图生视频)",
+8 -1
View File
@@ -140,7 +140,14 @@ func (c *Client) GenerateVideo(ctx context.Context, token, prompt, aspectRatio,
if artifact != "" {
break
}
// No artifact: grok closed the stream early. Retry.
// A fatal stream error means grok definitively rejected this generation
// (content moderation, an unsupported parameter, etc.). Retrying — on this
// or any other account — fails identically and only burns the pool, so fail
// fast with a non-temporary error the pool won't fail over on.
if strings.Contains(body, "STREAM_ERROR_SEVERITY_FATAL") {
return nil, nil, fmt.Errorf("grok: video generation rejected by upstream (fatal stream error): %s", clip([]byte(body), 200))
}
// No artifact and no fatal error: grok closed the stream early. Retry.
lastErr = nil
}
if artifact == "" {