MCPcopy Create free account
hub / github.com/Luce-Org/lucebox-hub / chat_post

Function chat_post

server/scripts/bench_agent_loop.py:59–66  ·  view source on GitHub ↗
(port: int, payload: dict, timeout=600)

Source from the content-addressed store, hash-verified

57
58
59def chat_post(port: int, payload: dict, timeout=600) -> str:
60 body = json.dumps(payload).encode()
61 req = urllib.request.Request(
62 f"http://127.0.0.1:{port}/v1/chat/completions",
63 data=body, headers={"Content-Type": "application/json"})
64 resp = urllib.request.urlopen(req, timeout=timeout)
65 data = json.loads(resp.read())
66 return data["choices"][0]["message"]["content"]
67
68
69def wait_server_up(port: int, proc: subprocess.Popen, timeout=180) -> bool:

Callers 1

run_configFunction · 0.70

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected