feat: LLM/Embedding 重试次数纳入 system.yaml 统一配置

- system.yaml: llm.max_retries(死配置) 改为 llm.max_attempts;embedding 段新增 max_attempts
- llm/client.py: LLMConfig 新增 max_attempts(默认 3 兜底),load_llm_config 读取配置
- llm/extractor.py: translate_and_extract(_async) max_attempts=None 时取 config.max_attempts
- embedding/client.py: load_embedding_config 读取 embedding.max_attempts
- scheduler/reporter.py: _call_llm_simple max_retries=None 时取 max_attempts-1
- 新增 2 个配置读取测试;已同步 pi5 验证
This commit is contained in:
2026-08-05 08:48:43 +08:00
parent d4a55bcaaa
commit 9aa44e610d
7 changed files with 37 additions and 7 deletions
+6
View File
@@ -25,6 +25,9 @@ _QWEN_DEFAULT_BASE = "https://dashscope.aliyuncs.com/compatible-mode/v1"
_DEEPSEEK_DEFAULT_MODEL = "deepseek-chat"
_QWEN_DEFAULT_MODEL = "qwen-plus"
# 默认单次调用总尝试次数(含首次;system.yaml llm.max_attempts 未配置时兜底)
_DEFAULT_MAX_ATTEMPTS = 3
def _load_system_config() -> dict:
"""加载 configs/system.yaml 中 llm 段配置。"""
@@ -50,6 +53,7 @@ class LLMConfig:
timeout_sec: float = 60.0
temperature: float = 0.1
max_tokens: int = 8192
max_attempts: int = _DEFAULT_MAX_ATTEMPTS # 单次调用总尝试次数(含首次)
def __post_init__(self) -> None:
if not self.api_key:
@@ -93,6 +97,7 @@ def load_llm_config(
timeout = float(config.get("timeout_sec", 60.0))
temperature = float(config.get("temperature", 0.1))
max_tokens = int(config.get("max_tokens", 8192))
max_attempts = int(config.get("max_attempts", _DEFAULT_MAX_ATTEMPTS))
return LLMConfig(
provider=p,
@@ -102,6 +107,7 @@ def load_llm_config(
timeout_sec=timeout,
temperature=temperature,
max_tokens=max_tokens,
max_attempts=max_attempts,
)