MCPcopy
hub / github.com/HKUDS/DeepTutor / probe_embedding

Function probe_embedding

deeptutor_cli/init_wizard.py:814–833  ·  view source on GitHub ↗

POST a tiny embedding request. Returns ``(ok, elapsed_ms, error)``.

(*, base_url: str, api_key: str, model: str)

Source from the content-addressed store, hash-verified

812
813
814def probe_embedding(*, base_url: str, api_key: str, model: str) -> tuple[bool, int, str]:
815 """POST a tiny embedding request. Returns ``(ok, elapsed_ms, error)``."""
816 if not base_url or not model:
817 return False, 0, "missing base_url or model"
818 started = time.monotonic()
819 try:
820 headers = {
821 "Authorization": f"Bearer {api_key or 'sk-no-key-required'}",
822 "Content-Type": "application/json",
823 }
824 body = {"model": model, "input": "ping"}
825 with httpx.Client(timeout=15.0) as client:
826 response = client.post(base_url, headers=headers, json=body)
827 elapsed = int((time.monotonic() - started) * 1000)
828 if response.status_code >= 400:
829 return False, elapsed, f"HTTP {response.status_code} · {response.text[:200]}"
830 return True, elapsed, ""
831 except Exception as exc:
832 elapsed = int((time.monotonic() - started) * 1000)
833 return False, elapsed, str(exc)[:200]
834
835
836# --- Review panel --------------------------------------------------------------

Callers

nothing calls this directly

Calls 2

strFunction · 0.50
postMethod · 0.45

Tested by

no test coverage detected