From 829e519be2c971047b9deaebd11c99a916903ccf Mon Sep 17 00:00:00 2001 From: Jidekin Date: Wed, 21 Oct 2026 10:46:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(sync):=20=E4=B8=AD=E5=9B=BD=E5=A4=A7?= =?UTF-8?q?=E9=99=86=E5=9C=B0=E5=8C=BA=E5=8F=97=E9=99=90=E7=9A=84=20OpenCo?= =?UTF-8?q?de=20=E6=A8=A1=E5=9E=8B=E4=B8=8D=E5=86=8D=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E8=BF=9B=E7=BD=91=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 文档 Go 页脚注写明了地区限制,之前只解析表格、把脚注漏了: Beam Free: Not available in ... China (including Hong Kong and Macau) ... Muse Spark 1.x Contributor: ... regions permitted by Meta's Geographic Use Policy 本机出口在中国大陆,实测 beam-free / muse-spark-1.3 / muse-spark-1.2 在 zen 与 inference 两条端点均 403 RegionError「This model is not available in your country」(同批 minimax-m3.1-flash-free / step-5-preview 均 200)。 新增 OC_REGION_BLOCKED 名单:同步时跳过(不新增;网关里已有的按已下线删除), 并在报告里单列「跳过(对中国大陆出口不可用,RegionError)」。 以后换境外出口或文档解除限制,把 id 从名单移走即可恢复。 --- scripts/sync_models.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scripts/sync_models.py b/scripts/sync_models.py index 9e91cba..61efeac 100755 --- a/scripts/sync_models.py +++ b/scripts/sync_models.py @@ -95,6 +95,25 @@ def _norm(s: str) -> str: OC_PROTOCOLS = ("chat/completions", "messages", "responses") OC_SKIPPED: list[str] = [] +# 2026-10-21:Go 页脚注里**写明了地区限制**,之前的解析只认表格、把脚注漏了 —— +# "Beam Free: Free for a limited time. Not available in Angola, Belarus, Cambodia, +# China (including Hong Kong and Macau), Cuba, the Democratic Republic of the Congo, +# Equatorial Guinea, Iran, Iraq, Laos, Libya, Nigeria, North Korea, Russia, Syria, +# Turkmenistan, Uz..." +# "Muse Spark 1.x Contributor: ... Availability is limited to regions permitted by +# Meta's Geographic Use Policy." +# 本机出口在中国大陆,实测这三个模型都是 403 RegionError「This model is not available +# in your country」(zen 与 inference 两条地址都试过,换地址没用;key 本身正常, +# 同批新模型 minimax-m3.1-flash-free / step-5-preview 都是 200)。 +# 口径:**跳过不落盘**——不新增;网关里已有的按"文档已不收录"处理(删掉)。 +# 以后换到境外出口、或文档解除限制,把 id 从这里移走即可恢复同步。 +OC_REGION_BLOCKED = { + "beam-free", + "muse-spark-1.3-contributor", + "muse-spark-1.2-contributor", +} +OC_REGION_SKIPPED: list[str] = [] + def _oc_protocol(url: str) -> str | None: """文档 Endpoint → 网关协议线;认不出返回 None。""" @@ -110,6 +129,7 @@ def fetch_opencode() -> dict[str, dict]: html = _get(OC_DOC_URL) models: dict[str, dict] = {} skipped: list[str] = [] + region_skipped: list[str] = [] for row in re.findall(r"(.*?)", html, re.S): cells = [_strip_tags(c) for c in re.findall(r"]*>(.*?)", row, re.S)] if len(cells) < 4 or "opencode.ai/" not in cells[2]: @@ -118,10 +138,14 @@ def fetch_opencode() -> dict[str, dict]: if proto is None: skipped.append(cells[1]) continue + if cells[1] in OC_REGION_BLOCKED: + region_skipped.append(cells[1]) + continue models[cells[1]] = {"name": cells[0], "protocol": proto, "free": False} if not models: raise RuntimeError("OpenCode 文档没解析出 Endpoints 表(页面可能改版)") OC_SKIPPED[:] = sorted(skipped) + OC_REGION_SKIPPED[:] = sorted(region_skipped) # 免费模型:价格表里 Input/Output 都是 Free 的那些(名字对 id 做归一匹配) by_norm = {_norm(mid): mid for mid in models} @@ -475,6 +499,7 @@ def diff(cfg: dict, oc_doc: dict, agnes_doc: dict, "free_drift": free_drift, "ctx_drift": oc_ctx_drift, "skipped": list(OC_SKIPPED), + "region_skipped": list(OC_REGION_SKIPPED), } # Agnes @@ -594,6 +619,9 @@ def render(report: dict) -> str: if oc.get("skipped"): lines.append(" 跳过(文档端点不是三条网关协议线,网关不支持):") lines += [f" · {m}" for m in oc["skipped"]] + if oc.get("region_skipped"): + lines.append(" 跳过(文档/实测:对中国大陆出口不可用,RegionError):") + lines += [f" · {m}" for m in oc["region_skipped"]] lines.append("") lines.append(f"== Agnes == 文档 {ag['doc_count']} 个 / 网关 {ag['cfg_count']} 个")