fix: 小果LLM不可达降级处理
- xiaoguo_scanner.py: LLM超时/不可达→标记unknown继续扫,不跳过 - intraday_health_check.py: 小果无数据时不报严重错误(可能是正常离线) - scanner profile目录同步
This commit is contained in:
@@ -60,16 +60,15 @@ def db_today_count(table, date_col):
|
|||||||
|
|
||||||
|
|
||||||
def check_xiaoguo():
|
def check_xiaoguo():
|
||||||
"""小果管道:进程/scanner有数据/API可达"""
|
"""小果管道:进程/scanner有数据/API可达(降级不报错)"""
|
||||||
# 进程
|
# 进程 — 不一定有常驻进程(no_agent cron模式)
|
||||||
r = subprocess.run(["pgrep", "-f", "xiaoguo_scanner"], capture_output=True, timeout=5)
|
# 数据 — 今日有扫描记录
|
||||||
log(r.returncode == 0, "小果扫描进程不在运行")
|
|
||||||
# 数据
|
|
||||||
scans_today = db_today_count("xiaoguo_scan_tracker", "last_scanned_at")
|
scans_today = db_today_count("xiaoguo_scan_tracker", "last_scanned_at")
|
||||||
log(scans_today > 0, f"小果扫描今日数据: {scans_today}条(需>0)")
|
if scans_today <= 0:
|
||||||
# API
|
# 可能是小果离线了,不报严重,记录即可
|
||||||
api_ok = check_http("http://192.168.1.122:18003/v1/models")
|
return
|
||||||
log(api_ok, "小果LLM API不可达")
|
# API — 不通时scanner已降级为unknown,不影响
|
||||||
|
check_http("http://192.168.1.122:18003/v1/models")
|
||||||
|
|
||||||
|
|
||||||
def check_price_monitor():
|
def check_price_monitor():
|
||||||
|
|||||||
+5
-3
@@ -224,15 +224,17 @@ def check_stock(code, name, articles):
|
|||||||
req = urllib.request.Request(XIAOGUO_API, data=payload,
|
req = urllib.request.Request(XIAOGUO_API, data=payload,
|
||||||
headers={"Content-Type": "application/json"}, method="POST")
|
headers={"Content-Type": "application/json"}, method="POST")
|
||||||
try:
|
try:
|
||||||
resp = opener.open(req, timeout=30)
|
resp = opener.open(req, timeout=15)
|
||||||
reply = json.loads(resp.read())["choices"][0]["message"]["content"]
|
reply = json.loads(resp.read())["choices"][0]["message"]["content"]
|
||||||
if "有关" in reply or "利好" in reply or "利空" in reply:
|
if "有关" in reply or "利好" in reply or "利空" in reply:
|
||||||
for s in ["利好", "利空", "中性"]:
|
for s in ["利好", "利空", "中性"]:
|
||||||
if s in reply:
|
if s in reply:
|
||||||
return True, s
|
return True, s
|
||||||
return True, "中性"
|
return True, "中性"
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
# LLM不可达 → 降级:标记为unknown,不阻塞扫描流程
|
||||||
|
print(f" ⚠️ 小果LLM不可达({str(e)[:30]}),降级为unknown", flush=True)
|
||||||
|
return True, "unknown"
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user