mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-01 13:33:48 +08:00
Fix: force set enable_thinking to true for preview qwen3 model (#17604)
This commit is contained in:
@@ -63,7 +63,9 @@ def knowledge_compile_gen_conf(chat_mdl, gen_conf: Optional[dict] = None) -> dic
|
||||
conf["extra_body"] = extra_body
|
||||
elif "qwen3" in model_name:
|
||||
# chat_model.py maps this flag to the provider-specific request body.
|
||||
conf["enable_thinking"] = False
|
||||
# -preview variants (e.g. qwen3.8-max-preview) only accept
|
||||
# enable_thinking=True on their API endpoint.
|
||||
conf["enable_thinking"] = True if "-preview" in model_name else False
|
||||
else:
|
||||
# LiteLLM maps this common control for providers that support it and
|
||||
# drops it for providers that do not. Keep model-specific overrides
|
||||
|
||||
@@ -151,7 +151,12 @@ def _apply_model_family_policies(
|
||||
# Qwen3 keeps RAGFlow's system default of disabling thinking unless explicitly overridden.
|
||||
if "qwen3" in model_name_lower:
|
||||
_pop_thinking_controls()
|
||||
enable_thinking = thinking_type == "enabled" if thinking_type else False
|
||||
# -preview variants (e.g. qwen3.8-max-preview) only accept
|
||||
# enable_thinking=True; the API rejects any other value.
|
||||
if "-preview" in model_name_lower:
|
||||
enable_thinking = True
|
||||
else:
|
||||
enable_thinking = thinking_type == "enabled" if thinking_type else False
|
||||
if backend == "litellm" and provider in {
|
||||
SupportedLiteLLMProvider.Tongyi_Qianwen,
|
||||
SupportedLiteLLMProvider.Dashscope,
|
||||
|
||||
@@ -46,6 +46,33 @@ def test_qwen3_can_enable_thinking_explicitly():
|
||||
assert kwargs["extra_body"] == {"seed": 1, "enable_thinking": True}
|
||||
|
||||
|
||||
def test_qwen3_preview_variant_forces_thinking_true():
|
||||
"""qwen3.x-preview models (e.g. qwen3.8-max-preview) only accept enable_thinking=True."""
|
||||
gen_conf, kwargs = _apply_model_family_policies(
|
||||
"qwen3.8-max-preview",
|
||||
backend="base",
|
||||
gen_conf={},
|
||||
request_kwargs={},
|
||||
)
|
||||
|
||||
assert gen_conf == {}
|
||||
assert kwargs["extra_body"]["enable_thinking"] is True
|
||||
|
||||
|
||||
def test_qwen3_preview_ignores_disabled_thinking():
|
||||
"""Even with thinking=disabled, -preview still forces enable_thinking=True."""
|
||||
gen_conf, kwargs = _apply_model_family_policies(
|
||||
"qwen3.8-max-preview",
|
||||
backend="base",
|
||||
gen_conf={"thinking": "disabled", "temperature": 0.2},
|
||||
request_kwargs={},
|
||||
)
|
||||
|
||||
assert "thinking" not in gen_conf
|
||||
assert gen_conf == {"temperature": 0.2}
|
||||
assert kwargs["extra_body"]["enable_thinking"] is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"provider",
|
||||
[SupportedLiteLLMProvider.Tongyi_Qianwen, SupportedLiteLLMProvider.Dashscope],
|
||||
|
||||
Reference in New Issue
Block a user