Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions researchclaw/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _is_timeout(exc: BaseException) -> bool:
return isinstance(reason, (TimeoutError, socket.timeout))


def check_llm_connectivity(base_url: str) -> CheckResult:
def check_llm_connectivity(base_url: str, api_key: str = "") -> CheckResult:
if not base_url.strip():
return CheckResult(
name="llm_connectivity",
Expand All @@ -171,10 +171,16 @@ def check_llm_connectivity(base_url: str) -> CheckResult:
)

url = _models_url(base_url)
req = urllib.request.Request(url, method="HEAD")
headers: dict[str, str] = {}
if api_key.strip():
headers["Authorization"] = f"Bearer {api_key}"
req = urllib.request.Request(url, headers=headers, method="HEAD")

try:
with urllib.request.urlopen(req, timeout=5):
with urllib.request.urlopen(
urllib.request.Request(url, headers=headers),
timeout=5,
):
return CheckResult(
name="llm_connectivity",
status="pass",
Expand Down Expand Up @@ -592,7 +598,7 @@ def run_doctor(config_path: str | Path) -> DoctorReport:
if provider == "acp":
checks.append(check_acp_agent(acp_agent_command))
else:
checks.append(check_llm_connectivity(base_url))
checks.append(check_llm_connectivity(base_url, api_key))
checks.append(check_api_key_valid(base_url, api_key))
checks.append(check_model_chain(base_url, api_key, model, fallback_models))
checks.append(check_sandbox_python(sandbox_python_path))
Expand Down