sync update from LAN repo (source dhk-1 @ 3e87be55)
This commit is contained in:
1 parent
ab6068a7c1
commit
42f2a26fa8
1482 files changed
+227759
-9584
No files matched your search
+32
-3
@@ -29,6 +29,10 @@ SourceType = Literal["web", "knowledge", "skill", "mcp", "file", "other"]
|
||||
# and the writing job harvests materials from that thread; ``legacy`` keeps the
|
||||
# runner-driven skill/web tiers searching on their own.
|
||||
CollectionMode = Literal["chat", "legacy"]
|
||||
# Who drafts the report skeleton when the user did not pick a preset structure.
|
||||
# ``agent`` — dedicated planner agent runs before collection.
|
||||
# ``pipeline`` — the writing job generates the outline itself (original fallback).
|
||||
OutlinePlanner = Literal["agent", "pipeline"]
|
||||
|
||||
# How the writer treats ``custom_outline``.
|
||||
# ``fixed`` (固定大纲) reproduces the stored headings and hierarchy.
|
||||
@@ -65,6 +69,8 @@ class DeepResearchConfig(BaseModel):
|
||||
|
||||
mode: ResearchMode = "basic"
|
||||
collection_mode: CollectionMode = "chat"
|
||||
# Missing snapshots (older sessions) stay on the writer fallback.
|
||||
outline_planner: OutlinePlanner = "pipeline"
|
||||
language: str = "zh-CN"
|
||||
tone: ResearchTone = "objective"
|
||||
report_format: ReportFormat = "markdown"
|
||||
@@ -184,6 +190,22 @@ class DeepResearchConfig(BaseModel):
|
||||
cleaned = str(value).replace("\x00", "").replace("\r", "").strip()
|
||||
return cleaned or None
|
||||
|
||||
@field_validator("outline_planner", mode="before")
|
||||
@classmethod
|
||||
def _normalize_outline_planner(cls, value: Any) -> OutlinePlanner:
|
||||
raw = str(value or "").strip().lower()
|
||||
if raw in {
|
||||
"agent",
|
||||
"planner",
|
||||
"智能体",
|
||||
"智能体规划",
|
||||
"先行规划大纲",
|
||||
"提纲预编制",
|
||||
"研究提纲预编制",
|
||||
}:
|
||||
return "agent"
|
||||
return "pipeline"
|
||||
|
||||
@field_validator("structure_mode", mode="before")
|
||||
@classmethod
|
||||
def _normalize_structure_mode(cls, value: Any) -> StructureMode:
|
||||
@@ -225,6 +247,13 @@ ALL_MODES: tuple[ResearchMode, ...] = (
|
||||
)
|
||||
|
||||
|
||||
def config_from_dict(data: dict[str, Any]) -> DeepResearchConfig:
|
||||
"""Build + clamp a config from a raw dict (e.g. JSON column / request body)."""
|
||||
return DeepResearchConfig.model_validate(data).clamp()
|
||||
def config_from_dict(data: dict[str, Any] | None) -> DeepResearchConfig:
|
||||
"""Build + clamp a config from a raw dict (e.g. JSON column / request body).
|
||||
|
||||
Persistence metadata (``report_variant``, ``parent_session_id``) and any
|
||||
other unknown keys are dropped before validation so a newer client cannot
|
||||
500 an older worker — ``extra="forbid"`` stays for direct model construction.
|
||||
"""
|
||||
raw = data if isinstance(data, dict) else {}
|
||||
payload = {key: value for key, value in raw.items() if key in DeepResearchConfig.model_fields}
|
||||
return DeepResearchConfig.model_validate(payload).clamp()
|
||||
Reference in new issue
Block a user