fix: 截断保护——输出<1500字且无信号时升级pro重试(flash懒答/截断导致信号丢失)
This commit is contained in:
@@ -421,6 +421,17 @@ def process_stock(code, force_today=False):
|
||||
print(f" \u2705 LLM返回({len(full_text)}字, {result['elapsed']:.1f}s, 尝试{result['attempts']}次)", flush=True)
|
||||
|
||||
parsed = parse_response(full_text)
|
||||
|
||||
# ── 截断保护:输出过短且无信号 = 低质输出,升级 pro 重试一次 ──
|
||||
if not parsed.get("signal") and len(full_text) < 1500:
|
||||
print(f" ⚠️ 输出截断({len(full_text)}字)且无信号,升级 {FALLBACK_MODEL} 重试...", flush=True)
|
||||
from llm_client import FALLBACK_MODEL as _FBM
|
||||
result2 = call_llm(prompt, model=_FBM, max_tokens=4096)
|
||||
if result2["ok"] and len((result2.get("content") or "").strip()) > len(full_text):
|
||||
full_text = result2["content"]
|
||||
parsed = parse_response(full_text)
|
||||
print(f" \u2705 升级后({len(full_text)}字)", flush=True)
|
||||
|
||||
print(f" 信号={parsed['signal']} 区间={parsed['entry_low']}~{parsed['entry_high']} 损={parsed['stop_loss']} 盈={parsed['take_profit']} 仓位={parsed['position']}")
|
||||
|
||||
save_result(code, full_text, parsed)
|
||||
|
||||
Reference in New Issue
Block a user