MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / call

Function call

scripts/decision-eval/eval2.py:21–33  ·  view source on GitHub ↗
(state, questions, retries=5)

Source from the content-addressed store, hash-verified

19
20
21def call(state, questions, retries=5):
22 body = json.dumps({"model": MODEL, "state": state, "questions": questions}).encode()
23 req = urllib.request.Request(API, data=body, method="POST", headers={"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"})
24 delay = 1.0
25 for attempt in range(retries):
26 try:
27 with urllib.request.urlopen(req, timeout=60) as r:
28 return json.load(r)
29 except urllib.error.HTTPError as e:
30 if e.code in (429, 529) and attempt < retries - 1:
31 time.sleep(delay); delay *= 2; continue
32 raise RuntimeError(f"HTTP {e.code}: {e.read().decode(errors='replace')[:200]}")
33 raise RuntimeError("retries exhausted")
34
35
36def run(jobs, workers=8):

Callers

nothing calls this directly

Calls 4

encodeMethod · 0.80
sleepMethod · 0.80
loadMethod · 0.65
readMethod · 0.45

Tested by

no test coverage detected