增加MiniMax海螺模型生图功能 - #2591
Conversation
fix: release workflow show version
Previously thoughtSignature was only attached to messages with function calls. This change extends the feature to also attach thoughtSignature to the first text part of assistant/model messages when no tool_calls are present, ensuring compatibility with Gemini thinking models in regular conversation scenarios.
fix: cast size to int64 before comparing with MaxUint32
fix: root page does not have analytic code
feat: add claude-opus-4-5-20251101
…ini-integration-011nJGemhrPUdqwg3qDvmqVB feat: enable thoughtSignature for non-function-call messages
fix: volcengine && baidu claude adapter
fix: volcengine claude DoResponse
fix: volcengine claude DoResponse
…pro-image-preview-oai OAI生图接口支持gemini 3 pro image preview
…ageConfig fix: gemini image correct generationConfig
…ith i18n - Add SSEViewer component for interactive SSE message inspection * Display SSE data stream with collapsible panels * Show parsed JSON with syntax highlighting * Display key information badges (content, tokens, finish reason) * Support copy individual or all SSE messages * Show error messages with detailed information - Support Ctrl+V to paste images in chat input * Enable image paste in CustomInputRender component * Auto-detect and add pasted images to image list * Show toast notifications for paste results - Add complete i18n support for 6 languages * Chinese (zh): Complete translations * English (en): Complete translations * Japanese (ja): Add 28 new translations * French (fr): Add 28 new translations * Russian (ru): Add 28 new translations * Vietnamese (vi): Add 32 new translations - Update .gitignore to exclude data directory
…-i2v Gemini Veo3.1[AI Studio]增加图生视频支持
Ensure image file is closed using defer after opening.
…edit Gemini Image系列支持图像编辑
…rim_suffix, ensure_prefix, ensure_suffix, trim_space, to_lower, to_upper, replace, and regex_replace
移除gorm:"default:false",避免每次 AutoMigrate时都执行ALTER TABLE `tokens` MODIFY COLUMN `cross_group_retry` boolean DEFAULT false 且bool默认false不影响原有功能
…ffaec308ac9c1cf2afa2de98c3d
* feat: add support for Doubao /v1/responses
…curity-check feat: check-in feature integrates Turnstile security check
fix: gemini request -> openai tool call
…QuantumNous#2556) * fix: fix model deployment style issues, lint problems, and i18n gaps. * fix: adjust the key not to be displayed on the frontend, tested via the backend. * fix: adjust the sidebar configuration logic to use the default configuration items if they are not defined.
…rride_trim_prefix
fix: 修复 gemini 文件类型不支持 image/jpg
…figuration && the AWS calling side did not apply the relay timeout.
fix: fix the proxyURL is empty, not using the default HTTP client configuration && the AWS calling side did not apply the relay timeout.
fix: add tips for model management and channel testing
问题描述: - 使用 auto 分组的令牌调用 /v1/videos 等 Task 接口时,虽然任务能成功创建, 但使用日志不显示记录,且不会扣费 根本原因: - Distribute 中间件在选择渠道后,会将实际选中的分组存储在 ContextKeyAutoGroup 中 - 但 RelayTaskSubmit 函数没有从 context 中读取这个值来更新 info.UsingGroup - 导致 info.UsingGroup 始终是 "auto" 而不是实际选中的分组(如 "sora2逆") - 当 auto 分组的倍率配置为 0 时,quota 计算结果为 0 - 日志记录条件 "if quota != 0" 不满足,导致日志不记录、不扣费 修复方案: - 在 RelayTaskSubmit 函数中计算分组倍率之前,添加从 ContextKeyAutoGroup 获取实际分组的逻辑 - 使用安全的类型断言,避免潜在的 panic 风险 影响范围: - 仅影响 Task Relay 流程(/v1/videos, /suno, /kling 等接口) - 不影响使用具体分组令牌的调用 - 不影响其他 Relay 类型(chat/completions 等已有类似处理逻辑)
…task-logging fix(task): 修复使用 auto 分组时 Task Relay 不记录日志和不扣费的问题
WalkthroughThis PR adds image generation and editing support to the Minimax relay channel. It introduces new DTOs for image operations, implements conversion functions from OpenAI format to Minimax format, adds image endpoint routing, and updates the adaptor with conditional image handling logic. Two new Minimax image models are registered. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Adaptor
participant ImageHandler
participant Minimax API
participant ResponseProcessor
Client->>Adaptor: POST (Images request, RelayMode=ImagesGenerations/ImagesEdits)
rect rgb(230, 245, 245)
Note over Adaptor: ConvertImageRequest
alt Edits Mode
Adaptor->>Adaptor: imageEditFromOai() - extract form base64 images
else GenerationMode
Adaptor->>Adaptor: oaiImageToHailuoImageRequest() - convert OpenAI format
end
Adaptor->>Adaptor: SetupRequestHeader - add Content-Type, Accept
end
Adaptor->>Minimax API: POST /v1/image_generation (converted request)
Minimax API-->>ImageHandler: HTTP response (status + body)
rect rgb(240, 250, 240)
Note over ImageHandler: imageHandler processing
ImageHandler->>ImageHandler: Read & validate response body
ImageHandler->>ImageHandler: Unmarshal to ImageGenerationResponse
ImageHandler->>ResponseProcessor: responseToOpenAIImage()
ResponseProcessor->>ResponseProcessor: Build ImageResponse with metadata
ResponseProcessor->>ResponseProcessor: Map URLs and base64 variants
alt Multiple images generated
ResponseProcessor->>ImageHandler: Update usage pricing
end
end
ImageHandler-->>Client: JSON (OpenAI-format ImageResponse)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~35 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
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 (5)
dto/values.go (1)
10-26: Consider handling JSONnullvalues explicitly.The current implementation will fail if the JSON value is
null- it will try to unmarshal as int (fail), then as string (succeed with empty string), thenstrconv.Atoi("")will return an error. Ifnullis a valid input for optional fields likeSeed, you may want to handle it gracefully.🔎 Proposed fix to handle null values
func (i *IntValue) UnmarshalJSON(b []byte) error { + if string(b) == "null" { + return nil + } var n int if err := json.Unmarshal(b, &n); err == nil { *i = IntValue(n) return nil }relay/channel/minimax/image.go (3)
25-28: Silently ignoring marshal/unmarshal errors may hide issues.The
Extrafield processing ignores bothjson.Marshalandjson.Unmarshalerrors. While this is likely intentional for optional fields, consider logging a warning if unmarshalling fails, as it could indicate malformed input.
114-114: Debug logging may include large base64 payloads.Logging the full
originBodyat debug level could result in very large log entries when base64-encoded images are included. Consider truncating or summarizing the response for debug purposes.
51-56: Consider accepting subject reference type from request parameters for flexibility.The
Typefield is hardcoded to"character". While this matches the standard use case documented in the MiniMax API, accepting the type from request parameters (if available) would allow for potential future extensibility and make the implementation more flexible.relay/channel/minimax/dto_image.go (1)
8-21: Consider using pointer types for optional numeric fields.
Width,Height, andNare non-pointerdto.IntValuetypes. Withomitempty, Go's JSON encoder only omits the field if the value is the zero value. However, sinceIntValueis anint, the zero value0will be omitted. If0is a valid value the user might want to send, this could cause issues.For fields where
0might be meaningful or where explicit omission is important, consider using*dto.IntValue(likeSeed).🔎 Proposed change for consistency
- Width dto.IntValue `json:"width,omitempty"` - Height dto.IntValue `json:"height,omitempty"` + Width *dto.IntValue `json:"width,omitempty"` + Height *dto.IntValue `json:"height,omitempty"`
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
dto/values.gorelay/channel/minimax/adaptor.gorelay/channel/minimax/constants.gorelay/channel/minimax/dto_image.gorelay/channel/minimax/image.gorelay/channel/minimax/relay-minimax.go
🧰 Additional context used
🧬 Code graph analysis (5)
relay/channel/minimax/relay-minimax.go (1)
relay/constant/relay_mode.go (2)
RelayModeImagesGenerations(14-14)RelayModeImagesEdits(15-15)
relay/channel/minimax/adaptor.go (2)
relay/constant/relay_mode.go (3)
RelayModeAudioSpeech(35-35)RelayModeImagesEdits(15-15)RelayModeImagesGenerations(14-14)types/set.go (1)
Set(3-5)
relay/channel/minimax/dto_image.go (2)
dto/values.go (1)
IntValue(8-8)relay/channel/task/hailuo/models.go (2)
SubjectReference(3-6)BaseResp(27-30)
dto/values.go (1)
common/json.go (2)
Unmarshal(9-11)Marshal(21-23)
relay/channel/minimax/image.go (4)
relay/channel/minimax/dto_image.go (4)
ImageGenerationRequest(8-21)StyleObject(28-31)ImageSubjectReference(23-26)ImageGenerationResponse(33-38)relay/channel/task/hailuo/models.go (2)
SubjectReference(3-6)BaseResp(27-30)relay/channel/task/hailuo/constants.go (1)
StatusSuccess(25-25)dto/openai_image.go (1)
ImageData(174-178)
🔇 Additional comments (9)
relay/channel/minimax/constants.go (1)
17-18: LGTM!The new image model entries follow the existing naming convention and align with the PR objectives for MiniMax image generation support.
relay/channel/minimax/relay-minimax.go (1)
22-23: LGTM!The new image generation and edit modes correctly route to the
/v1/image_generationendpoint, following the existing switch-case pattern for other relay modes.relay/channel/minimax/adaptor.go (3)
77-82: LGTM!The branching logic correctly differentiates between image edit and generation modes, routing to the appropriate handler functions.
94-97: LGTM!Setting explicit
Content-TypeandAcceptheaders for image modes ensures proper JSON communication with the MiniMax API.
124-135: LGTM!The response routing correctly handles audio, image generation, and image edit modes, with a fallback to the OpenAI adaptor for other cases.
relay/channel/minimax/image.go (2)
60-65: Verify graceful close behavior after ReadAll.
CloseResponseBodyGracefullyis called afterio.ReadAll. SinceReadAllconsumes the entire body, the close should work correctly, but ensure thatCloseResponseBodyGracefullyhandles already-consumed bodies gracefully.
101-112: No duplicate entries are possible with MiniMax's API design.The MiniMax image generation API uses the
response_formatparameter to control the response format, which can be either "url" or "base64"—not both. Whenresponse_format: "url"is used, onlyImageUrlsis populated; whenresponse_format: "base64"is used, onlyImageBase64is populated. The two formats are mutually exclusive at the API level, so the code cannot produce duplicate entries. The defensive iteration over both fields is safe and reasonable for robustness, but a single field will always be empty in any given response.Likely an incorrect or invalid review comment.
relay/channel/minimax/dto_image.go (2)
23-26: LGTM!The
ImageSubjectReferencestruct correctly models the subject reference with type and image file fields matching the MiniMax API requirements.
33-43: LGTM!The response structures properly model the MiniMax API response, reusing
BaseRespfor consistent error handling and separating image data into URLs and base64 formats.
官方文档:
https://platform.minimaxi.com/docs/api-reference/image-generation-i2i支持模型:
image-01, image-01-live支持格式:
openai的图片生成和图片编辑接口请求示例:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.