MCPcopy Create free account
hub / github.com/Continual-Intelligence/SEAL / _api

Function _api

general-knowledge/src/utils.py:70–86  ·  view source on GitHub ↗
(endpoint: str, payload: Dict[str, Any], timeout: int = 300)

Source from the content-addressed store, hash-verified

68
69
70def _api(endpoint: str, payload: Dict[str, Any], timeout: int = 300):
71 assert VLLM_API_URL, "VLLM API URL not set"
72 url = f"{VLLM_API_URL}/v1/{endpoint}"
73 for attempt in range(3):
74 try:
75 logging.debug("POST %s try %d payload %s", endpoint, attempt + 1, payload)
76 r = API.post(url, json=payload, timeout=timeout)
77 if r.status_code == 200:
78 if r.headers.get("Content-Type", "").startswith("application/json"):
79 return r.json()
80 return r.text or True
81 r.raise_for_status()
82 except Exception as e:
83 logging.warning("API error %s - attempt %d/3", e, attempt + 1)
84 time.sleep(2 * (attempt + 1))
85 logging.error("API %s failed after retries", endpoint)
86 return None
87
88
89def load_adapter(path: str, name: str) -> bool:

Callers 3

load_adapterFunction · 0.85
unload_adapterFunction · 0.85
generateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected