fix/crawler-proxy-config #42

Merged
starmen1265 merged 74 commits from fix/crawler-proxy-config into main 2026-03-24 00:21:02 +08:00
Showing only changes of commit bb321d9cd4 - Show all commits
+15 -4
View File
@@ -49,7 +49,8 @@ class SRTProcessor(BaseProcessor):
self,
state_manager: Optional[WorkflowStateManager] = None,
enable_correction: bool = True,
enable_semantic_segmentation: bool = False
enable_semantic_segmentation: bool = False,
enable_cache: bool = True
):
"""初始化 SRT 处理器
@@ -57,6 +58,7 @@ class SRTProcessor(BaseProcessor):
state_manager: 状态管理器
enable_correction: 是否启用 ASR 纠错(默认 True)
enable_semantic_segmentation: 是否启用 LLM 语义分段(默认 False)
enable_cache: 是否启用缓存(默认 True,仅在启用语义分段时有效)
"""
super().__init__(state_manager)
self.enable_correction = enable_correction
@@ -74,10 +76,19 @@ class SRTProcessor(BaseProcessor):
# 创建 AI 客户端
ai_client = SimpleAIClient()
if ai_client.api_key:
# 创建统一策略,传入 AI 客户端
strategy = UnifiedSegmentationStrategy(ai_client=ai_client)
# 初始化缓存
cache = None
if enable_cache:
from kb_workflow.srt.cache import SemanticCache
cache = SemanticCache()
# 创建统一策略,传入 AI 客户端和缓存
strategy = UnifiedSegmentationStrategy(
ai_client=ai_client,
cache=cache
)
self.segmenter = SemanticSegmentationEngine(strategy=strategy)
logger.info("Semantic segmentation enabled")
logger.info(f"Semantic segmentation enabled (cache={'enabled' if cache else 'disabled'})")
else:
logger.info("AI API key not configured, using rule-based segmenter")
self.segmenter = SemanticSegmenter()