MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / _validate_loopback_url

Function _validate_loopback_url

web/pgadmin/llm/providers/docker.py:51–64  ·  view source on GitHub ↗

Ensure the URL uses HTTP(S) and points to a loopback address.

(url: str)

Source from the content-addressed store, hash-verified

49
50
51def _validate_loopback_url(url: str) -> None:
52 """Ensure the URL uses HTTP(S) and points to a loopback address."""
53 parsed = urllib.parse.urlparse(url)
54 if parsed.scheme not in ('http', 'https'):
55 raise ValueError(
56 f"Docker Model Runner URL must use http or https, "
57 f"got: {parsed.scheme}"
58 )
59 hostname = (parsed.hostname or '').lower()
60 if hostname not in _LOOPBACK_HOSTS:
61 raise ValueError(
62 f"Docker Model Runner URL must point to a loopback address "
63 f"(localhost/127.0.0.1/::1), got: {hostname}"
64 )
65
66
67class DockerClient(LLMClient):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected