Files
iomgaa 547c9ddd84 feat(tree): TreeConfig 配置 dataclass
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-07-07 01:41:50 -04:00

43 lines
1.3 KiB
Python

"""建树模块配置。"""
from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True)
class TreeConfig:
"""建树配置参数,字段对齐 config/default.yaml 的 tree: 段。
参数:
l1_segment_duration: L1 段时长(秒)。
l2_clip_duration: L2 clip 时长(秒)。
l3_fps: L3 帧提取频率(帧/秒)。
l2_representative_frames: L2 VLM 描述用的代表帧数。
cache_dir: 树索引缓存目录。
concurrency: asyncio Semaphore 上限。
subtitle_inject: 建树时是否注入 SRT 字幕。
srt_window_sec: 字幕匹配时间窗口(前后各 N 秒)。
"""
l1_segment_duration: float = 600.0
l2_clip_duration: float = 60.0
l3_fps: float = 0.5
l2_representative_frames: int = 6
cache_dir: str = "cache/trees"
concurrency: int = 16
subtitle_inject: bool = True
srt_window_sec: float = 5.0
@classmethod
def from_dict(cls, d: dict) -> TreeConfig:
"""从 YAML 解析后的 dict 构造,忽略未知字段。
参数:
d: 配置字典。
返回:
TreeConfig 实例。
"""
return cls(**{k: v for k, v in d.items() if k in cls.__dataclass_fields__})