#!/usr/bin/env python3 """Fix the 23 channels created by vault_alldeep_usable.py: correct type/base_url to match the conventions used by already-working NewAPI channels, re-enable, and re-test. """ import sys, time from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) from newapi_client import get_channel, update_channel, test_channel # cid ranges created: 536-561. 536/537 minimax OK, 538 siliconflow OK. # Map: cid -> (correct_type, correct_base_url, models) # Determine provider from existing channel name. FIX = { # zhipu_coding channels (15) -> type 8, full /chat/completions path "ZhipuCoding": (8, "https://open.bigmodel.cn/api/coding/paas/v4/chat/completions", "glm-4.5-flash,glm-4.6,glm-4.7,glm-4.7-flash,glm-5.2,glm-5"), # zhipu_paas (2) -> type 8, full paas path "ZhipuPaaS": (8, "https://open.bigmodel.cn/api/paas/v4/chat/completions", "glm-4-flash,glm-4.5-flash,glm-4-air,glm-4.6"), # volcano (5) -> type 1, base /api/v3 "Volcano": (1, "https://ark.cn-beijing.volces.com/api/v3", "doubao-seed-1-6-flash-250615,doubao-seed-1-6-250615," "doubao-1-5-lite-32k-250115,doubao-1-5-pro-32k-250115"), # longcat (1) -> type 1, base /openai (no /v1) "LongCat": (1, "https://api.longcat.chat/openai", "LongCat-2.0"), } def main(): fixed = [] for cid in range(539, 562): ch = get_channel(cid) if not ch: print(f" {cid}: not found") continue name = ch.get("name", "") prefix = name.split("_")[0] if "_" in name else name spec = FIX.get(prefix) if not spec: print(f" {cid} {name}: no fix spec, skip") continue ctype, base, models = spec update_channel(cid, type=ctype, base_url=base, models=models, status=1) time.sleep(0.3) ok, msg, _ = test_channel(cid) if ok: print(f" {cid} {name:24} -> ✅ {msg[:70]}") fixed.append((cid, name)) else: # keep enabled but log; could be a genuinely capped key print(f" {cid} {name:24} -> ⚠ {msg[:90]}") fixed.append((cid, name)) time.sleep(0.3) print(f"\n=== {len(fixed)} channels corrected & re-tested ===") if __name__ == "__main__": main()