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 -2
View File
@@ -283,7 +283,7 @@ def _call_llm_simple(
system_prompt: str,
user_prompt: str,
max_tokens: int = 600,
max_retries: int = 2,
max_retries: int | None = None,
) -> str:
"""封装 LLM 调用,带重试和客户端复用。
@@ -291,7 +291,8 @@ def _call_llm_simple(
system_prompt: system role 内容
user_prompt: user role 内容
max_tokens: 最大输出 token
max_retries: 最大重试次数(不含首次调用
max_retries: 重试次数(不含首次)None 时取
config.max_attempts - 1system.yaml llm.max_attempts
Returns:
LLM 输出文本;所有重试均失败返回空字符串
@@ -308,6 +309,9 @@ def _call_llm_simple(
config = _llm_client_cache["config"]
client = _llm_client_cache[cache_key]
if max_retries is None:
max_retries = max(config.max_attempts - 1, 0)
last_err: str = ""
for attempt in range(1, max_retries + 2): # 首次 + max_retries 次重试
try: