# -*- coding: utf-8 -*- import json, sys, urllib.request, io, time sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') BASE = "http://127.0.0.1:8015" def post(path, payload, timeout=120): data = json.dumps(payload).encode('utf-8') req = urllib.request.Request(BASE+path, data=data, headers={'Content-Type':'application/json'}) t0=time.time() try: with urllib.request.urlopen(req, timeout=timeout) as r: body = r.read().decode('utf-8', 'replace') return r.status, body, round(time.time()-t0,1) except Exception as e: return 'ERR', str(e), round(time.time()-t0,1) # assistant/ask st, body, dt = post("/api/v1/assistant/ask", {"question":"你好,用一句话介绍你自己"}) print(f"[assistant/ask {st}] {dt}s len={len(body)}") print(" ", body[:600])