feat: 知识库文件夹/模板、技能压缩设置与摘要窗口调优
- 知识库新增文件夹与模板支持(模型/仓储/服务/迁移),前端知识管理组件 - 岗位管理模型与接口完善 - 技能新增压缩设置页与相关存储/工具能力 - 系统设置扩展配置项 - 摘要中间件 keep 窗口改用 token 预算(16000),减少重复压缩 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e6662cf673
commit
5ebbb82d66
54 files changed
+2658
-100
No files matched your search
+19
@@ -161,6 +161,10 @@ class SkillStateConfig(BaseModel):
|
||||
"""Configuration for a single skill's state."""
|
||||
|
||||
enabled: bool = Field(default=True, description="Whether this skill is enabled")
|
||||
always_on: bool = Field(
|
||||
default=False,
|
||||
description="常驻(免压缩):开启技能压缩后,本技能仍以全文形式注入系统提示词,而非降级为索引+search_skills 检索",
|
||||
)
|
||||
display: SkillDisplayConfig | None = Field(default=None, description="Optional frontend display adapter")
|
||||
|
||||
|
||||
@@ -313,6 +317,21 @@ class ExtensionsConfig(BaseModel):
|
||||
return skill_category in ("public", "custom")
|
||||
return skill_config.enabled
|
||||
|
||||
def is_skill_always_on(self, skill_name: str) -> bool:
|
||||
"""Check if a skill is marked 常驻(免压缩).
|
||||
|
||||
Args:
|
||||
skill_name: Name of the skill
|
||||
|
||||
Returns:
|
||||
True if the skill should bypass skill compression, False otherwise
|
||||
(default for skills without an explicit config entry).
|
||||
"""
|
||||
skill_config = self.skills.get(skill_name)
|
||||
if skill_config is None:
|
||||
return False
|
||||
return skill_config.always_on
|
||||
|
||||
|
||||
_extensions_config: ExtensionsConfig | None = None
|
||||
|
||||
|
||||
@@ -170,6 +170,26 @@ class LeaderboardSettings(BaseModel):
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class SkillCompressionSettings(BaseModel):
|
||||
"""Admin-configurable skill compression (技能压缩).
|
||||
|
||||
When ``enabled``, only skills explicitly marked 常驻(免压缩) (``always_on``)
|
||||
are injected full-text into the lead agent's system prompt. Every other
|
||||
enabled skill is "compressed": kept out of the prompt body and surfaced to
|
||||
the agent on demand via the ``search_skills`` keyword-retrieval tool (and a
|
||||
compact name index when ``keep_index_in_prompt`` is true). When disabled the
|
||||
behaviour is unchanged — every enabled skill is injected full-text.
|
||||
"""
|
||||
|
||||
enabled: bool = Field(default=False, description="Whether skill compression is active (master switch)")
|
||||
search_top_n: int = Field(default=5, ge=1, le=50, description="Max skills returned by the search_skills tool")
|
||||
keep_index_in_prompt: bool = Field(
|
||||
default=True,
|
||||
description="Whether compressed skills still appear as a compact name-only index in the prompt",
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class SystemSettings(BaseModel):
|
||||
"""Top-level system settings document."""
|
||||
|
||||
@@ -179,6 +199,7 @@ class SystemSettings(BaseModel):
|
||||
appearance: AppearanceSettings = Field(default_factory=AppearanceSettings)
|
||||
citation_display: CitationDisplaySettings = Field(default_factory=CitationDisplaySettings)
|
||||
leaderboard: LeaderboardSettings = Field(default_factory=LeaderboardSettings)
|
||||
skill_compression: SkillCompressionSettings = Field(default_factory=SkillCompressionSettings)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
@@ -204,6 +225,15 @@ def load_system_settings() -> SystemSettings:
|
||||
return SystemSettings()
|
||||
|
||||
|
||||
def get_skill_compression_settings() -> SkillCompressionSettings:
|
||||
"""Convenience accessor for the skill-compression block (safe defaults on error)."""
|
||||
try:
|
||||
return load_system_settings().skill_compression
|
||||
except Exception:
|
||||
logger.debug("Failed to read skill compression settings; using defaults", exc_info=True)
|
||||
return SkillCompressionSettings()
|
||||
|
||||
|
||||
def save_system_settings(settings: SystemSettings) -> SystemSettings:
|
||||
"""Persist the settings document atomically, returning the saved value."""
|
||||
path = _settings_path()
|
||||
|
||||
Reference in new issue
Block a user