import json, urllib.request, websocket
req = urllib.request.Request("http://10.168.3.36:8081/api/login",
    data=json.dumps({"username": "cxbsoft", "password": "cf5584aca177a811ffda8f4789e2e143"}).encode(),
    headers={"Content-Type": "application/json"})
token = json.load(urllib.request.urlopen(req, timeout=10)).get("data", {}).get("token", "")
ws = websocket.create_connection("ws://10.168.3.36:8081/api/user/friend-agent/ws?access_token=" + token, timeout=20)
ws.settimeout(25)
def req2(method, params, rid):
    ws.send(json.dumps({"type": "req", "request_id": rid, "method": method, "params": params}))
    while True:
        m = json.loads(ws.recv())
        if m.get("request_id") == rid:
            return m
r = req2("llm.routes.get", {}, "r1")
routes = r.get("result", {})
print("=== routes.get 原始结构（brain_thinking）===")
print(json.dumps(routes.get("brain_thinking", routes), ensure_ascii=False, indent=1)[:800])
r2 = req2("llm.channels.list", {}, "r2")
chs = r2.get("result", {})
chlist = chs.get("channels", chs) if isinstance(chs, dict) else chs
print("=== 渠道模型数 ===")
for c in chlist if isinstance(chlist, list) else []:
    print(" channel:", c.get("id"), c.get("name"), "models:", len(c.get("models", [])), "sample:", [m.get("model_key") or m.get("id") for m in c.get("models", [])[:3]])
ws.close()
