import json import sys import urllib.request try: sys.stdout.reconfigure(encoding="utf-8", errors="replace") except Exception: pass URL = "http://127.0.0.1:15199" def call(path, payload=None, method="POST", timeout=60): data = json.dumps(payload, ensure_ascii=False).encode("utf-8") if payload is not None else None req = urllib.request.Request( URL + path, data=data, method=method, headers={"Content-Type": "application/json; charset=utf-8"}, ) with urllib.request.urlopen(req, timeout=timeout) as r: return json.loads(r.read().decode("utf-8")) convs = call("/api/conversations", method="GET").get("conversations") or [] print("会话:") for c in convs: print(" ", c.get("id"), "|", c.get("title"), "| 消息", c.get("messageCount"), "| updated", c.get("updatedAt")) # 直接看 c_main 里到底有没有消息 full = call("/api/conversations/c_main", method="GET").get("conversation") or {} msgs = full.get("messages") or [] print(f"\nc_main 里 {len(msgs)} 条消息:") for m in msgs: print(" ", m.get("role"), "|", repr((m.get("content") or "")[:60]))