mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-03 06:12:14 +08:00
fix(config): fix summarization model alias resolution (#1378)
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
@@ -58,7 +58,7 @@ def _create_summarization_middleware() -> SummarizationMiddleware | None:
|
|||||||
|
|
||||||
# Prepare model parameter
|
# Prepare model parameter
|
||||||
if config.model_name:
|
if config.model_name:
|
||||||
model = config.model_name
|
model = create_chat_model(name=config.model_name, thinking_enabled=False)
|
||||||
else:
|
else:
|
||||||
# Use a lightweight model for summarization to save costs
|
# Use a lightweight model for summarization to save costs
|
||||||
# Falls back to default model if not explicitly specified
|
# Falls back to default model if not explicitly specified
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from deerflow.agents.lead_agent import agent as lead_agent_module
|
|||||||
from deerflow.config.app_config import AppConfig
|
from deerflow.config.app_config import AppConfig
|
||||||
from deerflow.config.model_config import ModelConfig
|
from deerflow.config.model_config import ModelConfig
|
||||||
from deerflow.config.sandbox_config import SandboxConfig
|
from deerflow.config.sandbox_config import SandboxConfig
|
||||||
|
from deerflow.config.summarization_config import SummarizationConfig
|
||||||
|
|
||||||
|
|
||||||
def _make_app_config(models: list[ModelConfig]) -> AppConfig:
|
def _make_app_config(models: list[ModelConfig]) -> AppConfig:
|
||||||
@@ -135,3 +136,29 @@ def test_build_middlewares_uses_resolved_model_name_for_vision(monkeypatch):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert any(isinstance(m, lead_agent_module.ViewImageMiddleware) for m in middlewares)
|
assert any(isinstance(m, lead_agent_module.ViewImageMiddleware) for m in middlewares)
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_summarization_middleware_uses_configured_model_alias(monkeypatch):
|
||||||
|
monkeypatch.setattr(
|
||||||
|
lead_agent_module,
|
||||||
|
"get_summarization_config",
|
||||||
|
lambda: SummarizationConfig(enabled=True, model_name="model-masswork"),
|
||||||
|
)
|
||||||
|
|
||||||
|
captured: dict[str, object] = {}
|
||||||
|
fake_model = object()
|
||||||
|
|
||||||
|
def _fake_create_chat_model(*, name=None, thinking_enabled, reasoning_effort=None):
|
||||||
|
captured["name"] = name
|
||||||
|
captured["thinking_enabled"] = thinking_enabled
|
||||||
|
captured["reasoning_effort"] = reasoning_effort
|
||||||
|
return fake_model
|
||||||
|
|
||||||
|
monkeypatch.setattr(lead_agent_module, "create_chat_model", _fake_create_chat_model)
|
||||||
|
monkeypatch.setattr(lead_agent_module, "SummarizationMiddleware", lambda **kwargs: kwargs)
|
||||||
|
|
||||||
|
middleware = lead_agent_module._create_summarization_middleware()
|
||||||
|
|
||||||
|
assert captured["name"] == "model-masswork"
|
||||||
|
assert captured["thinking_enabled"] is False
|
||||||
|
assert middleware["model"] is fake_model
|
||||||
|
|||||||
Reference in New Issue
Block a user