From b13259df5f9663f70b85b50e419bf43994d7dc9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Wed, 8 Jul 2026 20:04:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20market=5Fscreener=E5=B0=8F=E6=9E=9C?= =?UTF-8?q?=E7=A6=BB=E7=BA=BF=E9=99=8D=E7=BA=A7+2=E7=A7=92=E5=BF=AB?= =?UTF-8?q?=E9=80=9F=E6=8E=A2=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/market_screener.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/market_screener.py b/scripts/market_screener.py index 23192841..4cf35a09 100644 --- a/scripts/market_screener.py +++ b/scripts/market_screener.py @@ -47,9 +47,22 @@ def call_xiaoguo(messages, timeout=API_TIMEOUT): resp = urllib.request.build_opener(urllib.request.ProxyHandler({})).open(req, timeout=timeout) return json.loads(resp.read())["choices"][0]["message"]["content"] except Exception as e: - print(f"API失败: {e}", flush=True) + print(f"⚠️ 小果API不可用: {e}", flush=True) return None +def xiaoguo_available(): + """快速探测小果是否在线(2秒超时)""" + try: + req = urllib.request.Request(_get_xiaoguo_url(), + data=b'{"model":"Qwen3.6-27B-OptiQ-4bit","messages":[{"role":"user","content":"ok"}],"max_tokens":1}', + headers={"Content-Type": "application/json", + "Authorization": "Bearer hermes123"}, method="POST") + urllib.request.build_opener(urllib.request.ProxyHandler({})).open(req, timeout=2) + return True + except Exception: + return False + + def extract_json(text): """从回复中提取第一个完整JSON,跳过思考过程""" @@ -242,6 +255,19 @@ def main(): sectors = market["sectors"] source = market.get("source", "db") print(f"板块: {len(sectors)}, 来源: {source}", flush=True) + + # 快速探测小果是否在线,不在线就降级 + if not xiaoguo_available(): + print("⚠️ 小果不在线,跳过LLM分析,仅保存板块数据", flush=True) + save_json(DATA_DIR / "market_scan_summary.json", { + "timestamp": datetime.now().strftime("%Y-%m-%d %H:%M"), + "source": source, + "sector_count": len(sectors), + "xiaoguo_status": "offline", + "note": "小果不在线,未做LLM全市场筛选", + }) + return + pool = load_pool() existing = {c["code"] for c in pool.get("candidates", []) if not c.get("dropped")}