fix(llm): 修复 MiniMax thinking 关闭无效#604
Merged
H-Chris233 merged 1 commit intoJun 6, 2026
Merged
Conversation
**Bug 复现** 用户在 OpenLess 设置里把「思考」关闭后,MiniMax(M3)润色仍输出 thinking 内容块,UI 关闭形同虚设。 **根因** polish.rs::openai_compatible_thinking_control 只在 5 个 provider_id (deepseek / openrouterFree / alibabaCoding / openai / codingPlanX) 上分派 thinking 控制参数;MiniMax 不在列表里,走默认 _ => None 分支,后端根本 不下发 thinking 字段。M3 默认开启 thinking,所以 UI 关闭后服务端仍 输出 <think>…</think> 块。 **修复** - 新增 ThinkingControl::MiniMaxThinking 变体:关闭下发 `thinking.type = "disabled"`、开启下发 `thinking.type = "adaptive"`, 与 minimaxi 官方 Chat Completions schema 完全对齐。 - openai_compatible_thinking_control 增加 "minimax" provider_id 识别。 - 同时增加 base_url 兜底识别(host 含 "minimax" 关键字即命中),让用户 用「自定义」preset 接入 MiniMax 时也能正确下发 thinking 控制参数。 - 前端 ProvidersSection.tsx::LLM_PRESETS 新增 minimax preset (baseUrl=https://api.minimaxi.com/v1, model=MiniMax-M3)。 - 5 个 i18n 文件 (en/zh-CN/zh-TW/ja/ko) 加 minimax 文案。 - 加 4 个 Rust 单元测试覆盖:preset 命中、adaptive 字面量、custom base_url 兜底、host 提取对尾斜杠与路径的容错。 **兼容性** - 旧 provider (deepseek/openai/codingPlanX/alibabaCoding/openrouterFree) 行为完全不变,新增 case 仅在 provider_id 命中 minimax 或 base_url 含 minimaxi 主机时启用。 - 行为对齐 minimaxi 官方文档: https://platform.minimaxi.com/docs/api-reference/text-chat-openai#thinking-控制 **测试** cargo test --lib polish:: 41 passed, 0 failed 新增 4 个 case: - openai_chat_body_disables_minimax_thinking_by_preset - openai_chat_body_enables_minimax_thinking_with_adaptive_literal - openai_chat_body_falls_back_to_base_url_for_custom_minimax_endpoint - openai_chat_body_base_url_fallback_respects_trailing_slash_and_path
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Bug 复现
在 OpenLess 设置里把「思考」关掉后,接入 MiniMax (M3) 润色时仍持续输出
<think>…</think>块,UI 关闭形同虚设。根因
polish.rs::openai_compatible_thinking_control只在 5 个 provider_id 上分派 thinking 控制:MiniMax 不在列表里,走到
None => {}分支,后端根本不下发thinking字段。M3 默认开启 thinking,服务端继续输出 内容块。修复
新增
ThinkingControl::MiniMaxThinking变体 —— schema 与 DeepSeek 相同(body.thinking.type),但取值字面量与 minimaxi 官方一致:"disabled""adaptive"(DeepSeek 用的是"enabled",MiniMax 文档不支持,发"enabled"M3 会 400)openai_compatible_thinking_control增加"minimax"provider_id 识别新增
openai_compatible_thinking_control_for_base_url兜底识别 —— host 含minimax关键字时命中,让用户用「自定义」preset 接入 MiniMax 也能正确下发 thinking 控制参数。同样的兜底也覆盖了 deepseek / openrouter / dashscope。前端
LLM_PRESETS新增minimaxpreset —— baseUrlhttps://api.minimaxi.com/v1,model 占位MiniMax-M3。5 个 i18n 文件 (en/zh-CN/zh-TW/ja/ko) 加
minimax文案 key。4 个 Rust 单元测试 覆盖:preset 命中、
adaptive字面量、custom base_url 兜底、host 提取对尾斜杠与路径的容错。兼容性
minimax或 base_url 主机名含minimax时启用。disabled服务端仍保持开启),与 OpenLess「渠道级按官方参数声明下发」策略一致,不维护单模型白名单。参考文档
测试
新增 4 个 case:
openai_chat_body_disables_minimax_thinking_by_preset— provider_id 命中,关闭下发disabledopenai_chat_body_enables_minimax_thinking_with_adaptive_literal— 开启下发adaptive(不是enabled)openai_chat_body_falls_back_to_base_url_for_custom_minimax_endpoint—custompreset +https://api.minimaxi.com/v1也能命中openai_chat_body_base_url_fallback_respects_trailing_slash_and_path— host 提取对/v1、/v1/、裸域名都正确PR Type
Bug fix
Description
Fix MiniMax thinking control not being applied when disabled in UI
Add MiniMaxThinking variant with correct "disabled"/"adaptive" values
Implement base_url fallback for custom endpoint
Add frontend preset and i18n for MiniMax
Diagram Walkthrough
flowchart LR A["User disables thinking in settings"] --> B{"provider_id?"} B -- "minimax" --> C["MiniMaxThinking return 'disabled'"] B -- "custom" --> D["base_url fallback detects 'minimax'"] D --> C C --> E["body.thinking.type = 'disabled'"] E --> F["MiniMax API stops thinking"]File Walkthrough
1 files
Add MiniMax thinking control variant and base_url fallback5 files
Add MiniMax i18n labelAdd MiniMax i18n labelAdd MiniMax i18n labelAdd MiniMax i18n labelAdd MiniMax i18n label1 files
Add MiniMax preset to LLM_PRESETS