aboutsummaryrefslogtreecommitdiff
path: root/app/backends/probe.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/backends/probe.py')
-rw-r--r--app/backends/probe.py21
1 files changed, 21 insertions, 0 deletions
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.