MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / api_get

Function api_get

libtv-skill/scripts/_common.py:57–70  ·  view source on GitHub ↗

GET 请求 agent-im OpenAPI

(path: str)

Source from the content-addressed store, hash-verified

55
56
57def api_get(path: str) -> dict:
58 """GET 请求 agent-im OpenAPI"""
59 url = f"{IM_BASE.rstrip('/')}{path}"
60 req = urllib.request.Request(url, method="GET", headers=_headers())
61 try:
62 with urllib.request.urlopen(req, timeout=30) as resp:
63 return json.loads(resp.read().decode("utf-8"))
64 except urllib.error.HTTPError as e:
65 err_body = e.read().decode("utf-8") if e.fp else ""
66 print(f"API 错误 {e.code}: {err_body}", file=sys.stderr)
67 sys.exit(1)
68 except urllib.error.URLError as e:
69 print(f"网络错误: {e.reason}", file=sys.stderr)
70 sys.exit(1)
71
72
73def create_session(session_id: str = "", message: str = "") -> dict:

Callers 1

query_sessionFunction · 0.85

Calls 1

_headersFunction · 0.85

Tested by

no test coverage detected