fix: parse_response取应为/修正为后的正确区间——不再把LLM重复的旧脏值(95~99)当推荐写回

This commit is contained in:
xxm
2026-08-18 10:57:13 +08:00
parent 7329c651b0
commit 9543dd52e8
+12 -5
View File
@@ -459,11 +459,18 @@ def parse_response(text):
if re.search(r'\s*(无|不设|不参与|空仓)', zl): if re.search(r'\s*(无|不设|不参与|空仓)', zl):
result["zone_cleared"] = True result["zone_cleared"] = True
else: else:
nums = re.findall(r'\d+\.?\d*', zl) # 2026-08-18 修复:LLM 说"95~99(异常,应为14.87~15.01"时,取"应为"后的正确区间
if len(nums) >= 2: # 否则取前两个数字(避免旧脏值被当推荐值写回,老莫 600262 教训)
a, b = float(nums[0]), float(nums[1]) _corrected = re.search(r'(?:应为|修正为|改为|更正为)\s*[(]?([\d.]+)\s*[~-]\s*([\d.]+)', zl)
result["entry_low"] = min(a, b) if _corrected:
result["entry_high"] = max(a, b) result["entry_low"] = float(_corrected.group(1))
result["entry_high"] = float(_corrected.group(2))
else:
nums = re.findall(r'\d+\.?\d*', zl)
if len(nums) >= 2:
a, b = float(nums[0]), float(nums[1])
result["entry_low"] = min(a, b)
result["entry_high"] = max(a, b)
# 止损(只认【建议止损】节行) # 止损(只认【建议止损】节行)
for name in ("建议止损", "止损"): for name in ("建议止损", "止损"):