sync update from LAN repo (source master @ c21a2a4a)
This commit is contained in:
1 parent
ea9dcff9c0
commit
66a443e915
140 files changed
+13777
-1040
No files matched your search
@@ -482,13 +482,14 @@ def _load_and_cache_app_config(config_path: str | None = None) -> AppConfig:
|
||||
)
|
||||
performance = _app_config.runtime_performance
|
||||
logger.info(
|
||||
"RUNTIME_PERFORMANCE skill_view_reuse_enabled=%s skill_view_cache_enabled=%s model_timing_nonblocking_enabled=%s asyncio_thread_pool_enabled=%s asyncio_thread_pool_size=%d tool_metrics_enabled=%s",
|
||||
"RUNTIME_PERFORMANCE skill_view_reuse_enabled=%s skill_view_cache_enabled=%s model_timing_nonblocking_enabled=%s asyncio_thread_pool_enabled=%s asyncio_thread_pool_size=%d tool_metrics_enabled=%s skill_metrics_enabled=%s",
|
||||
performance.skill_view_reuse_enabled,
|
||||
performance.skill_view_cache_enabled,
|
||||
performance.model_timing_nonblocking_enabled,
|
||||
performance.asyncio_thread_pool_enabled,
|
||||
performance.asyncio_thread_pool_size,
|
||||
performance.tool_metrics_enabled,
|
||||
performance.skill_metrics_enabled,
|
||||
)
|
||||
return _app_config
|
||||
|
||||
|
||||
+19
-5
@@ -2,9 +2,11 @@
|
||||
|
||||
Skill-view reuse and cache are on when those keys are absent. Set them to
|
||||
false in config.yaml to restore a full refresh on every tool call. Model
|
||||
timing and the Gateway thread pool stay off unless configured. If application
|
||||
configuration cannot be loaded, every switch stays off. Tool-call metric writes
|
||||
are paused by default; explicitly enable them to resume audit statistics.
|
||||
timing and the Gateway thread pool stay off unless configured. Tool and skill
|
||||
metrics are on by default so the management leaderboard has a complete source
|
||||
of truth. Deployments that need to shed this best-effort audit write load can
|
||||
explicitly pause either metric type in ``config.yaml``. If configuration
|
||||
cannot be loaded, the fallback keeps every switch off.
|
||||
"""
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
@@ -15,7 +17,14 @@ class RuntimePerformanceConfig(BaseModel):
|
||||
|
||||
skill_view_reuse_enabled: bool = Field(default=True, description="Reuse one verified skill view within each sandbox tool invocation. Set false to refresh on every call.")
|
||||
skill_view_cache_enabled: bool = Field(default=True, description="Reuse unchanged skill views after validating source, target and availability versions. Set false to rebuild every call.")
|
||||
tool_metrics_enabled: bool = Field(default=False, description="Persist tool/skill audit statistics to tool_call_metrics. Disabled by default to avoid competing with interactive database traffic; historical reads remain available.")
|
||||
tool_metrics_enabled: bool = Field(
|
||||
default=True,
|
||||
description="Persist tool/skill audit statistics to tool_call_metrics. Enabled by default so management leaderboard tool rankings receive data; set false only to pause ordinary tool auditing.",
|
||||
)
|
||||
skill_metrics_enabled: bool = Field(
|
||||
default=True,
|
||||
description="Persist calls that can be attributed to a concrete skill, keeping skill statistics available even if ordinary tool auditing is paused.",
|
||||
)
|
||||
model_timing_nonblocking_enabled: bool = Field(default=False, description="Dispatch model timing logs through a dedicated bounded queue, outside the shared tool executor")
|
||||
asyncio_thread_pool_enabled: bool = Field(default=False, description="Override the Gateway event loop's default executor at startup; disabled preserves Python defaults")
|
||||
asyncio_thread_pool_size: int = Field(default=100, ge=1, le=1024, strict=True, description="Maximum Gateway executor threads when enabled, unless overridden by the documented environment variables")
|
||||
@@ -24,7 +33,12 @@ class RuntimePerformanceConfig(BaseModel):
|
||||
# Field defaults turn the skill-view fast path on. This fallback is only for
|
||||
# callers that cannot read application configuration, and it keeps every
|
||||
# switch off.
|
||||
_DEFAULT = RuntimePerformanceConfig(skill_view_reuse_enabled=False, skill_view_cache_enabled=False)
|
||||
_DEFAULT = RuntimePerformanceConfig(
|
||||
skill_view_reuse_enabled=False,
|
||||
skill_view_cache_enabled=False,
|
||||
tool_metrics_enabled=False,
|
||||
skill_metrics_enabled=False,
|
||||
)
|
||||
|
||||
|
||||
def get_runtime_performance_config() -> RuntimePerformanceConfig:
|
||||
|
||||
+264
-1
@@ -21,7 +21,7 @@ from pathlib import Path
|
||||
from typing import Literal
|
||||
from uuid import uuid4
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
||||
|
||||
from deerflow.config.llmwiki_config import LlmWikiRuntimeOverride
|
||||
from deerflow.config.runtime_paths import runtime_home
|
||||
@@ -474,6 +474,20 @@ class SkillCompressionSettings(BaseModel):
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class SkillVersioningSettings(BaseModel):
|
||||
"""Deployment-wide gate for custom-skill package version history.
|
||||
|
||||
The default is intentionally disabled so existing deployments retain the
|
||||
legacy in-place editing behaviour until an administrator opts in.
|
||||
"""
|
||||
|
||||
enabled: bool = Field(
|
||||
default=False,
|
||||
description="Whether custom-skill package versioning and switching are enabled",
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class AgentModuleSettings(BaseModel):
|
||||
"""Admin-configured「按类型聚合」module → selected agent-tag ids.
|
||||
|
||||
@@ -668,6 +682,24 @@ class WriteFileCompatibilitySettings(BaseModel):
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class CallMetricsSettings(BaseModel):
|
||||
"""Administrator-controlled recording for tool and skill call statistics.
|
||||
|
||||
Both rankings use the same ``tool_call_metrics`` audit stream. Keeping a
|
||||
single switch prevents a partially enabled configuration where the
|
||||
management page can show one ranking but not the other.
|
||||
"""
|
||||
|
||||
enabled: bool = Field(
|
||||
default=True,
|
||||
description=(
|
||||
"Whether new tool and skill calls are persisted for management "
|
||||
"statistics. Existing records are retained when disabled."
|
||||
),
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class RetryKeepPartialSettings(BaseModel):
|
||||
"""Keep already-streamed partial answers visible across silent LLM retries.
|
||||
|
||||
@@ -717,6 +749,15 @@ class RoundtableRoomLimitSettings(BaseModel):
|
||||
"but never extend this deadline."
|
||||
),
|
||||
)
|
||||
lease_minutes: int = Field(
|
||||
default=5,
|
||||
ge=1,
|
||||
le=60,
|
||||
description=(
|
||||
"How long a foreground step-2 lease stays occupied without a renewal. "
|
||||
"The browser heartbeat renews it; this does not extend max_hold_minutes."
|
||||
),
|
||||
)
|
||||
max_cycles: int = Field(
|
||||
default=8,
|
||||
ge=2,
|
||||
@@ -769,7 +810,40 @@ class HtmlMapSettings(BaseModel):
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
_GENERATED_PAGE_LOGO_FILE_RE = re.compile(r"^logo-[a-f0-9]{32}\.(?:png|jpg|webp)$")
|
||||
|
||||
|
||||
class GeneratedPageBrandingSettings(BaseModel):
|
||||
"""Optional generated-page logo settings retained for offline bundles."""
|
||||
|
||||
chrome_enabled: bool = True
|
||||
header_layout: Literal["left", "center"] = "center"
|
||||
system_name: str | None = Field(default=None, max_length=80)
|
||||
footer_text: str | None = Field(default=None, max_length=160)
|
||||
logo_filename: str | None = None
|
||||
logo_mode: Literal["custom", "default", "none"] = "custom"
|
||||
logo_media_type: Literal["image/png", "image/jpeg", "image/webp"] | None = None
|
||||
logo_version: str | None = Field(default=None, max_length=64)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
@field_validator("logo_filename")
|
||||
@classmethod
|
||||
def _validate_logo_filename(cls, value: str | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
normalized = str(value).strip().lower()
|
||||
if not _GENERATED_PAGE_LOGO_FILE_RE.fullmatch(normalized):
|
||||
raise ValueError("Invalid generated-page logo filename")
|
||||
return normalized
|
||||
|
||||
|
||||
_APP_IDENTITY_LOGO_FILE_RE = re.compile(r"^logo-[a-f0-9]{32}\.(?:png|jpg|webp)$")
|
||||
_APP_IDENTITY_LIGHT_RED_HEADER_FILE_RE = re.compile(
|
||||
r"^light-red-header-[a-f0-9]{32}\.(?:png|jpg|webp|svg)$"
|
||||
)
|
||||
_APP_IDENTITY_LIGHT_RED_ACTIVE_FILE_RE = re.compile(
|
||||
r"^light-red-active-[a-f0-9]{32}\.(?:png|jpg|webp|svg)$"
|
||||
)
|
||||
|
||||
|
||||
class AppIdentitySettings(BaseModel):
|
||||
@@ -780,9 +854,21 @@ class AppIdentitySettings(BaseModel):
|
||||
"""
|
||||
|
||||
system_name: str = Field(default="", max_length=80)
|
||||
header_title_font_mode: Literal["adaptive", "fixed"] = "adaptive"
|
||||
header_title_font_size: int = Field(default=30, ge=16, le=40)
|
||||
logo_filename: str | None = None
|
||||
logo_media_type: Literal["image/png", "image/jpeg", "image/webp"] | None = None
|
||||
logo_version: str | None = None
|
||||
light_red_header_background_filename: str | None = None
|
||||
light_red_header_background_media_type: Literal[
|
||||
"image/png", "image/jpeg", "image/webp", "image/svg+xml"
|
||||
] | None = None
|
||||
light_red_header_background_version: str | None = None
|
||||
light_red_nav_active_filename: str | None = None
|
||||
light_red_nav_active_media_type: Literal[
|
||||
"image/png", "image/jpeg", "image/webp", "image/svg+xml"
|
||||
] | None = None
|
||||
light_red_nav_active_version: str | None = None
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
@field_validator("system_name")
|
||||
@@ -801,6 +887,26 @@ class AppIdentitySettings(BaseModel):
|
||||
raise ValueError("Invalid application logo filename")
|
||||
return normalized
|
||||
|
||||
@field_validator("light_red_header_background_filename")
|
||||
@classmethod
|
||||
def _validate_light_red_header_filename(cls, value: str | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
normalized = str(value).strip().lower()
|
||||
if not _APP_IDENTITY_LIGHT_RED_HEADER_FILE_RE.fullmatch(normalized):
|
||||
raise ValueError("Invalid light-red header background filename")
|
||||
return normalized
|
||||
|
||||
@field_validator("light_red_nav_active_filename")
|
||||
@classmethod
|
||||
def _validate_light_red_active_filename(cls, value: str | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
normalized = str(value).strip().lower()
|
||||
if not _APP_IDENTITY_LIGHT_RED_ACTIVE_FILE_RE.fullmatch(normalized):
|
||||
raise ValueError("Invalid light-red active navigation filename")
|
||||
return normalized
|
||||
|
||||
|
||||
def app_identity_logo_path(
|
||||
settings: AppIdentitySettings | None = None,
|
||||
@@ -814,6 +920,42 @@ def app_identity_logo_path(
|
||||
return path if path.is_file() else None
|
||||
|
||||
|
||||
def app_identity_light_red_header_background_path(
|
||||
settings: AppIdentitySettings | None = None,
|
||||
) -> Path | None:
|
||||
"""Resolve the uploaded light-red header background inside runtime storage."""
|
||||
|
||||
current = settings or load_system_settings().app_identity
|
||||
if not current.light_red_header_background_filename:
|
||||
return None
|
||||
path = runtime_home() / "app-identity" / current.light_red_header_background_filename
|
||||
return path if path.is_file() else None
|
||||
|
||||
|
||||
def app_identity_light_red_nav_active_path(
|
||||
settings: AppIdentitySettings | None = None,
|
||||
) -> Path | None:
|
||||
"""Resolve the uploaded light-red active-navigation image inside runtime storage."""
|
||||
|
||||
current = settings or load_system_settings().app_identity
|
||||
if not current.light_red_nav_active_filename:
|
||||
return None
|
||||
path = runtime_home() / "app-identity" / current.light_red_nav_active_filename
|
||||
return path if path.is_file() else None
|
||||
|
||||
|
||||
def generated_page_logo_path(
|
||||
settings: GeneratedPageBrandingSettings | None = None,
|
||||
) -> Path | None:
|
||||
"""Resolve the custom generated-page logo without accepting arbitrary paths."""
|
||||
|
||||
current = settings or load_system_settings().generated_page_branding
|
||||
if current.logo_mode != "custom" or not current.logo_filename:
|
||||
return None
|
||||
path = runtime_home() / "generated-page-branding" / current.logo_filename
|
||||
return path if path.is_file() else None
|
||||
|
||||
|
||||
class HtmlRuntimeSettings(BaseModel):
|
||||
"""Addresses written into newly generated HTML pages.
|
||||
|
||||
@@ -844,6 +986,108 @@ class StrategyProjectSettings(BaseModel):
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class GeneralQaPageDescription(BaseModel):
|
||||
"""Administrator-provided copy for the ordinary Q&A landing page."""
|
||||
|
||||
welcome_title: str = Field(default="", max_length=80)
|
||||
welcome_description: str = Field(default="", max_length=500)
|
||||
input_placeholder: str = Field(default="", max_length=120)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
@field_validator("welcome_title", "welcome_description", "input_placeholder")
|
||||
@classmethod
|
||||
def _normalize_copy(cls, value: str | None) -> str:
|
||||
return str(value or "").strip()
|
||||
|
||||
|
||||
class GeneralQaPageDescriptions(BaseModel):
|
||||
"""Separate ordinary-Q&A copy for the full and compact layouts."""
|
||||
|
||||
full: GeneralQaPageDescription = Field(default_factory=GeneralQaPageDescription)
|
||||
compact: GeneralQaPageDescription = Field(default_factory=GeneralQaPageDescription)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _migrate_legacy_single_description(cls, value: object) -> object:
|
||||
if isinstance(value, GeneralQaPageDescription):
|
||||
return {"full": value, "compact": value}
|
||||
if not isinstance(value, dict):
|
||||
return value
|
||||
if "full" in value or "compact" in value:
|
||||
return value
|
||||
legacy = {
|
||||
key: value.get(key, "")
|
||||
for key in ("welcome_title", "welcome_description", "input_placeholder")
|
||||
}
|
||||
return {"full": legacy, "compact": legacy}
|
||||
|
||||
|
||||
class PageHeaderDescription(BaseModel):
|
||||
"""Configurable title and explanatory copy for a product landing page."""
|
||||
|
||||
title: str = Field(default="", max_length=80)
|
||||
description: str = Field(default="", max_length=500)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
@field_validator("title", "description")
|
||||
@classmethod
|
||||
def _normalize_copy(cls, value: str | None) -> str:
|
||||
return str(value or "").strip()
|
||||
|
||||
|
||||
class AIWritingGuideCard(BaseModel):
|
||||
"""Editable text for one of the fixed AI-writing welcome cards."""
|
||||
|
||||
title: str = Field(default="", max_length=80)
|
||||
description: str = Field(default="", max_length=240)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
@field_validator("title", "description")
|
||||
@classmethod
|
||||
def _normalize_copy(cls, value: str | None) -> str:
|
||||
return str(value or "").strip()
|
||||
|
||||
|
||||
def _empty_ai_writing_guide_cards() -> list[AIWritingGuideCard]:
|
||||
return [AIWritingGuideCard() for _ in range(3)]
|
||||
|
||||
|
||||
class AIWritingPageDescription(PageHeaderDescription):
|
||||
"""Configurable copy for the classic AI-writing welcome page."""
|
||||
|
||||
guide_cards: list[AIWritingGuideCard] = Field(
|
||||
default_factory=_empty_ai_writing_guide_cards,
|
||||
max_length=3,
|
||||
)
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _keep_three_guide_cards(cls, value: object) -> object:
|
||||
if not isinstance(value, dict) or not isinstance(value.get("guide_cards"), list):
|
||||
return value
|
||||
cards = value["guide_cards"][:3]
|
||||
return {**value, "guide_cards": [*cards, *({} for _ in range(3 - len(cards)))]}
|
||||
|
||||
|
||||
class PageDescriptionsSettings(BaseModel):
|
||||
"""Page-scoped, administrator-managed display copy."""
|
||||
|
||||
general_qa: GeneralQaPageDescriptions = Field(default_factory=GeneralQaPageDescriptions)
|
||||
knowledge_base: PageHeaderDescription = Field(default_factory=PageHeaderDescription)
|
||||
ai_writing: AIWritingPageDescription = Field(default_factory=AIWritingPageDescription)
|
||||
strategy_projects: PageHeaderDescription = Field(default_factory=PageHeaderDescription)
|
||||
deep_research: PageHeaderDescription = Field(default_factory=PageHeaderDescription)
|
||||
gongwen: PageHeaderDescription = Field(default_factory=PageHeaderDescription)
|
||||
light_app_management: PageHeaderDescription = Field(default_factory=PageHeaderDescription)
|
||||
light_app_list: PageHeaderDescription = Field(default_factory=PageHeaderDescription)
|
||||
agents: PageHeaderDescription = Field(default_factory=PageHeaderDescription)
|
||||
business_chains: PageHeaderDescription = Field(default_factory=PageHeaderDescription)
|
||||
skills: PageHeaderDescription = Field(default_factory=PageHeaderDescription)
|
||||
knowledge_management: PageHeaderDescription = Field(default_factory=PageHeaderDescription)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class ModelPromptSuffix(BaseModel):
|
||||
"""Administrator-owned instructions appended to one configured model's system prompt."""
|
||||
|
||||
@@ -862,9 +1106,14 @@ class SystemSettings(BaseModel):
|
||||
private_square: PrivateSquareSettings = Field(default_factory=PrivateSquareSettings)
|
||||
publish_squares: PublishSquaresSettings = Field(default_factory=PublishSquaresSettings)
|
||||
appearance: AppearanceSettings = Field(default_factory=AppearanceSettings)
|
||||
generated_page_branding: GeneratedPageBrandingSettings = Field(
|
||||
default_factory=GeneratedPageBrandingSettings
|
||||
)
|
||||
page_descriptions: PageDescriptionsSettings = Field(default_factory=PageDescriptionsSettings)
|
||||
citation_display: CitationDisplaySettings = Field(default_factory=CitationDisplaySettings)
|
||||
leaderboard: LeaderboardSettings = Field(default_factory=LeaderboardSettings)
|
||||
skill_compression: SkillCompressionSettings = Field(default_factory=SkillCompressionSettings)
|
||||
skill_versioning: SkillVersioningSettings = Field(default_factory=SkillVersioningSettings)
|
||||
plugin_management: PluginManagementSettings = Field(default_factory=PluginManagementSettings)
|
||||
agent_modules: AgentModuleSettings = Field(default_factory=AgentModuleSettings)
|
||||
wx_common_agents: WxCommonAgentsSettings = Field(default_factory=WxCommonAgentsSettings)
|
||||
@@ -875,6 +1124,7 @@ class SystemSettings(BaseModel):
|
||||
write_file_compatibility: WriteFileCompatibilitySettings = Field(
|
||||
default_factory=WriteFileCompatibilitySettings
|
||||
)
|
||||
call_metrics: CallMetricsSettings = Field(default_factory=CallMetricsSettings)
|
||||
retry_keep_partial: RetryKeepPartialSettings = Field(
|
||||
default_factory=RetryKeepPartialSettings
|
||||
)
|
||||
@@ -1007,6 +1257,19 @@ def get_write_file_compatibility_settings() -> WriteFileCompatibilitySettings:
|
||||
return WriteFileCompatibilitySettings()
|
||||
|
||||
|
||||
def get_call_metrics_settings() -> CallMetricsSettings:
|
||||
"""Return the live call-metrics switch, defaulting to recording enabled."""
|
||||
|
||||
try:
|
||||
return load_system_settings().call_metrics
|
||||
except Exception:
|
||||
logger.debug(
|
||||
"Failed to read call metrics setting; keeping metrics enabled",
|
||||
exc_info=True,
|
||||
)
|
||||
return CallMetricsSettings()
|
||||
|
||||
|
||||
def get_roundtable_room_limit_settings() -> RoundtableRoomLimitSettings:
|
||||
"""Return the admin-controlled roundtable room cap, defaulting to 3 enabled rooms."""
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user