sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)
This commit is contained in:
1 parent
4f7f07504a
commit
8bc8b0e082
1651 files changed
+278599
-11416
No files matched your search
+171
-4
@@ -147,6 +147,15 @@ class CustomThemePreset(BaseModel):
|
||||
return _normalize_optional_hex_color(value, "Theme text color")
|
||||
|
||||
|
||||
WordHeadingNumberingStyle = Literal[
|
||||
"hybrid_decimal",
|
||||
"official_chinese",
|
||||
"decimal",
|
||||
"chapter_section",
|
||||
"none",
|
||||
]
|
||||
|
||||
|
||||
class PromptPrefixSettings(BaseModel):
|
||||
"""Admin-configurable first-message prompt prefix."""
|
||||
|
||||
@@ -157,6 +166,10 @@ class PromptPrefixSettings(BaseModel):
|
||||
default=False,
|
||||
description="Whether the formal Markdown heading rules are injected into ordinary Q&A system prompts.",
|
||||
)
|
||||
word_heading_numbering_style: WordHeadingNumberingStyle = Field(
|
||||
default="hybrid_decimal",
|
||||
description="Heading-numbering preset used by every Markdown-to-Word export.",
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
@@ -273,6 +286,7 @@ class AppearanceSettings(BaseModel):
|
||||
class CitationDisplaySettings(BaseModel):
|
||||
"""System-wide controls for citation mode entry and display cleanup."""
|
||||
|
||||
retrieved_files_enabled: bool = True
|
||||
reference_mode_enabled: bool = Field(
|
||||
default=False,
|
||||
description="Whether the reference-mode entry points are exposed to users.",
|
||||
@@ -414,6 +428,22 @@ class AgentModuleSettings(BaseModel):
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class WxCommonAgentsSettings(BaseModel):
|
||||
"""The gallery category shown in the wx chat route's common-agent panel.
|
||||
|
||||
``None`` keeps the original recommendation logic. ``mine`` and
|
||||
``sentiment`` are built-in category values. Publish-square categories are
|
||||
persisted as ``square:<square_id>`` so they cannot collide with the
|
||||
built-ins.
|
||||
"""
|
||||
|
||||
agent_type: str | None = Field(
|
||||
default=None,
|
||||
description="Selected gallery category; null retains the default recommendation logic",
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class PluginDomainAgentMapping(BaseModel):
|
||||
"""One configured host -> agent mapping for iframe chat auto-selection."""
|
||||
|
||||
@@ -447,6 +477,16 @@ def set_module_tag_ids(settings: AgentModuleSettings, key: str, tag_ids: list[st
|
||||
return settings.model_copy(update={"modules": modules})
|
||||
|
||||
|
||||
class AuthenticationSettings(BaseModel):
|
||||
"""Public login capabilities; administrator writes take effect immediately."""
|
||||
|
||||
password_login_enabled: bool = False
|
||||
registration_enabled: bool = False
|
||||
sso_enabled: bool = True
|
||||
single_session_enabled: bool = False
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
|
||||
class LoginWhitelistSettings(BaseModel):
|
||||
"""登录白名单总开关(管理员可在「白名单管理」页切换,即时生效、免重启)。
|
||||
|
||||
@@ -505,14 +545,93 @@ class ModelConcurrencySettings(BaseModel):
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class MemoryRuntimeSettings(BaseModel):
|
||||
"""Deployment-wide switch for generic/personal Q&A memory.
|
||||
|
||||
Memory is deliberately opt-in. When this setting is false the lead agent
|
||||
does not mount memory middleware or memory tools, does not inject stored
|
||||
generic memory into prompts, and does not enqueue generic background memory
|
||||
extraction. Project-scoped Q&A memory is an independent subsystem governed
|
||||
by each project's own setting and is intentionally not controlled here.
|
||||
"""
|
||||
|
||||
enabled: bool = Field(
|
||||
default=False,
|
||||
description="Whether generic/personal Q&A memory recall, injection and persistence are enabled.",
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class WriteFileCompatibilitySettings(BaseModel):
|
||||
"""Deployment-wide compatibility for gateways buffering tool arguments."""
|
||||
|
||||
enabled: bool = Field(
|
||||
default=False,
|
||||
description=(
|
||||
"Whether every compatible model uses the buffered-gateway "
|
||||
"write_file streaming adapter."
|
||||
),
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class ConversationContextSettings(BaseModel):
|
||||
"""Deployment-wide short-context policy for chat model requests.
|
||||
|
||||
The recent-turn window is deliberately opt-in. When enabled, the lead
|
||||
agent keeps the persisted conversation intact but sends only the latest
|
||||
three real user turns (plus their assistant/tool continuations) to the
|
||||
model. This avoids an extra summarization-model call while preserving the
|
||||
complete transcript for the UI and checkpoint recovery.
|
||||
"""
|
||||
|
||||
recent_turn_window_enabled: bool = Field(
|
||||
default=False,
|
||||
description="Whether model requests use the fixed recent-three-turn sliding window.",
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class LocalWikiEncoderSettings(BaseModel):
|
||||
"""Runtime override for the administrator-managed offline Wiki encoder."""
|
||||
|
||||
mode: Literal["configured", "local"] = Field(
|
||||
default="configured",
|
||||
description=(
|
||||
"Use the embedding provider from config.yaml, or explicitly override it "
|
||||
"with the administrator-managed offline BGE-M3 encoder."
|
||||
),
|
||||
)
|
||||
model_path: str = Field(
|
||||
default="",
|
||||
max_length=4096,
|
||||
description="Absolute or project-relative directory containing the offline BGE-M3 ONNX model.",
|
||||
)
|
||||
model_revision: str = Field(
|
||||
default="",
|
||||
max_length=64,
|
||||
description="Opaque revision changed whenever an offline model directory is activated.",
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class HtmlMapSettings(BaseModel):
|
||||
"""Which map engine newly generated HTML pages should use."""
|
||||
|
||||
engine: Literal["echarts", "leaflet"] = Field(
|
||||
default="echarts",
|
||||
description="echarts uses local GeoJSON; leaflet is the tile-based map webpage",
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class StrategyProjectSettings(BaseModel):
|
||||
"""Global visibility controls for the strategy-project experience."""
|
||||
|
||||
taiwan_strait_demo_enabled: bool = Field(
|
||||
default=False,
|
||||
description="Whether Taiwan Strait demo entry points are visible in My Projects.",
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
@@ -521,6 +640,7 @@ class SystemSettings(BaseModel):
|
||||
|
||||
prompt_prefix: PromptPrefixSettings = Field(default_factory=PromptPrefixSettings)
|
||||
login_whitelist: LoginWhitelistSettings = Field(default_factory=LoginWhitelistSettings)
|
||||
authentication: AuthenticationSettings = Field(default_factory=AuthenticationSettings)
|
||||
private_square: PrivateSquareSettings = Field(default_factory=PrivateSquareSettings)
|
||||
publish_squares: PublishSquaresSettings = Field(default_factory=PublishSquaresSettings)
|
||||
appearance: AppearanceSettings = Field(default_factory=AppearanceSettings)
|
||||
@@ -529,14 +649,25 @@ class SystemSettings(BaseModel):
|
||||
skill_compression: SkillCompressionSettings = Field(default_factory=SkillCompressionSettings)
|
||||
plugin_management: PluginManagementSettings = Field(default_factory=PluginManagementSettings)
|
||||
agent_modules: AgentModuleSettings = Field(default_factory=AgentModuleSettings)
|
||||
wx_common_agents: WxCommonAgentsSettings = Field(default_factory=WxCommonAgentsSettings)
|
||||
concurrency_monitor: ConcurrencyMonitorSettings = Field(default_factory=ConcurrencyMonitorSettings)
|
||||
model_concurrency: ModelConcurrencySettings = Field(default_factory=ModelConcurrencySettings)
|
||||
memory: MemoryRuntimeSettings = Field(default_factory=MemoryRuntimeSettings)
|
||||
write_file_compatibility: WriteFileCompatibilitySettings = Field(
|
||||
default_factory=WriteFileCompatibilitySettings
|
||||
)
|
||||
conversation_context: ConversationContextSettings = Field(default_factory=ConversationContextSettings)
|
||||
local_wiki_encoder: LocalWikiEncoderSettings = Field(default_factory=LocalWikiEncoderSettings)
|
||||
strategy_projects: StrategyProjectSettings = Field(default_factory=StrategyProjectSettings)
|
||||
html_map: HtmlMapSettings = Field(default_factory=HtmlMapSettings)
|
||||
llmwiki: LlmWikiRuntimeOverride = Field(default_factory=LlmWikiRuntimeOverride)
|
||||
skill_knowledge_auto_sync: SkillKnowledgeAutoSyncSettings = Field(default_factory=SkillKnowledgeAutoSyncSettings)
|
||||
knowledge_base_product_version: Literal["v1", "v2"] = Field(
|
||||
default="v1",
|
||||
description="v1 opens the ordinary WeKnora experience; v2 opens the DeerFlow assistant knowledge base.",
|
||||
description=(
|
||||
"v1 keeps assistant-knowledge day-to-day surfaces admin-only; "
|
||||
"v2 releases them to ordinary users while ordinary knowledge remains the default landing."
|
||||
),
|
||||
)
|
||||
ordinary_knowledge_landing: Literal["wiki", "weknora"] = "wiki"
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
@@ -591,12 +722,48 @@ def get_model_concurrency_settings() -> ModelConcurrencySettings:
|
||||
return ModelConcurrencySettings()
|
||||
|
||||
|
||||
def get_memory_runtime_settings() -> MemoryRuntimeSettings:
|
||||
"""Return the admin-controlled Q&A memory switch, failing closed."""
|
||||
try:
|
||||
return load_system_settings().memory
|
||||
except Exception:
|
||||
logger.debug("Failed to read memory runtime setting; keeping memory disabled", exc_info=True)
|
||||
return MemoryRuntimeSettings()
|
||||
|
||||
|
||||
def get_write_file_compatibility_settings() -> WriteFileCompatibilitySettings:
|
||||
"""Return the global buffered-gateway switch, failing closed."""
|
||||
|
||||
try:
|
||||
return load_system_settings().write_file_compatibility
|
||||
except Exception:
|
||||
logger.debug(
|
||||
"Failed to read write_file compatibility setting; keeping native transport",
|
||||
exc_info=True,
|
||||
)
|
||||
return WriteFileCompatibilitySettings()
|
||||
|
||||
|
||||
def get_conversation_context_settings() -> ConversationContextSettings:
|
||||
"""Return the admin-controlled recent-turn policy, failing closed."""
|
||||
try:
|
||||
return load_system_settings().conversation_context
|
||||
except Exception:
|
||||
logger.debug("Failed to read conversation context setting; keeping the recent-turn window disabled", exc_info=True)
|
||||
return ConversationContextSettings()
|
||||
|
||||
|
||||
def save_system_settings(settings: SystemSettings) -> SystemSettings:
|
||||
"""Persist the settings document atomically, returning the saved value."""
|
||||
path = _settings_path()
|
||||
payload = settings.model_dump(mode="json")
|
||||
with _lock:
|
||||
tmp = path.with_suffix(path.suffix + ".tmp")
|
||||
tmp.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
tmp.replace(path)
|
||||
# Multiple Gateway workers share this file. A unique temporary name
|
||||
# prevents their atomic replaces from racing over one common `.tmp`.
|
||||
tmp = path.with_name(f".{path.name}.{uuid4().hex}.tmp")
|
||||
try:
|
||||
tmp.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
tmp.replace(path)
|
||||
finally:
|
||||
tmp.unlink(missing_ok=True)
|
||||
return settings
|
||||
Reference in new issue
Block a user