From 6cfcd564c0684c52618235e6366f4a81c02b9a5b Mon Sep 17 00:00:00 2001 From: historia Date: Tue, 1 Sep 2026 14:32:05 -0400 Subject: slop refactor/dedup --- app/backends/probe.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'app/backends/probe.py') diff --git a/app/backends/probe.py b/app/backends/probe.py index 64dc7ab..818aadb 100644 --- a/app/backends/probe.py +++ b/app/backends/probe.py @@ -142,6 +142,27 @@ def same_endpoint(url_a: str, url_b: str) -> bool: return host_a == host_b and port_a == port_b +def detect_remote_url(remote_url: str, local_url: str, identity: str, + name: str, managed: bool = False) -> tuple: + """The shared backend "is something answering at the remote URL?" check. + + Returns ``(running, {name: url})``. An empty URL disables the check; a + remote URL equal to the configured local endpoint is ignored while + MANAGED (that server was started by this tool and is already reported + as "[local]"); otherwise the URL must answer HTTP as IDENTITY to count. + The faster and audio.cpp backends use it verbatim; qwen's is + model-aware and keeps its own variant. + """ + url = (remote_url or "").strip() + if not url: + return False, {} + if managed and same_endpoint(url, local_url): + return False, {} + if identify_server(url) == identity: + return True, {name: url} + return False, {} + + def health_payload(url: str, timeout: float = DEFAULT_TIMEOUT) -> Optional[dict]: """Return the server's ``/health`` JSON document, or None. -- cgit v1.2.3