fix(provider): strip <think> tags and merge system messages for MiniMax
MiniMax API rejects role: system in the messages array with error 2013 (invalid message role: system). In channel mode, the history builder prepends a system message and optionally appends a second one for delivery instructions, causing 400 errors on every channel turn. Additionally, MiniMax reasoning models embed chain-of-thought in the content field as <think>...</think> blocks rather than using the separate reasoning_content field, causing raw thinking output to leak into user-visible responses. Changes: - Add merge_system_into_user flag to OpenAiCompatibleProvider; when set, all system messages are concatenated and prepended to the first user message before sending to the API - Add new_merge_system_into_user() constructor used by MiniMax - Add strip_think_tags() helper that removes <think>...</think> blocks from response content before returning to the caller - Apply strip_think_tags in effective_content() and effective_content_optional() so all non-streaming paths are covered - Update MiniMax factory registration to use new_merge_system_into_user - Fix pre-existing rustfmt violation on apply_auth_header call All other providers continue to use the default path unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d33eadea75
commit
db7b24b319
2 changed files with 121 additions and 22 deletions
|
|
@ -661,12 +661,14 @@ pub fn create_provider_with_url(
|
|||
AuthStyle::Bearer,
|
||||
)))
|
||||
}
|
||||
name if minimax_base_url(name).is_some() => Ok(Box::new(OpenAiCompatibleProvider::new(
|
||||
"MiniMax",
|
||||
minimax_base_url(name).expect("checked in guard"),
|
||||
key,
|
||||
AuthStyle::Bearer,
|
||||
))),
|
||||
name if minimax_base_url(name).is_some() => Ok(Box::new(
|
||||
OpenAiCompatibleProvider::new_merge_system_into_user(
|
||||
"MiniMax",
|
||||
minimax_base_url(name).expect("checked in guard"),
|
||||
key,
|
||||
AuthStyle::Bearer,
|
||||
)
|
||||
)),
|
||||
"bedrock" | "aws-bedrock" => Ok(Box::new(OpenAiCompatibleProvider::new(
|
||||
"Amazon Bedrock",
|
||||
"https://bedrock-runtime.us-east-1.amazonaws.com",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue