fix: LLM空输出视为失败 + save_result拒绝写入空分析(防止假时间戳跳过机制失效)

This commit is contained in:
hmo
2026-07-22 00:24:47 +08:00
parent c1b38d3d7b
commit 40852de280
+6 -3
View File
@@ -326,7 +326,10 @@ def parse_response(text):
return result
def save_result(code, full_text, parsed):
"""保存LLM结果到DB(先快照再UPDATE"""
"""保存LLM结果到DB(先快照再UPDATE。空分析拒绝写入。"""
if not (full_text or "").strip():
print(f" \u274c 拒绝写入空分析(LLM输出为空,保护已有数据)")
return
conn = sqlite3.connect(DB)
now = datetime.now().isoformat()
@@ -410,8 +413,8 @@ def process_stock(code, force_today=False):
# ── 使用共享 LLM 客户端(替代 curl subprocess)──
result = call_llm(prompt, model=REASSESS_MODEL, max_tokens=4096)
if not result["ok"]:
print(f" \u274c LLM调用失败: {result.get('error','未知错误')}")
if not result["ok"] or not (result.get("content") or "").strip():
print(f" \u274c LLM调用失败或空输出: {result.get('error') or 'empty content'}")
return False
full_text = result["content"]