diff options
| author | historia <historiavg@proton.me> | 2026-09-01 14:32:05 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-09-01 14:32:05 -0400 |
| commit | 6cfcd564c0684c52618235e6366f4a81c02b9a5b (patch) | |
| tree | 55321760a8103bc6b5d79489fac4135a60e6e3ba /app/backends/probe.py | |
| parent | dc6e7cd43029da62dabe2513fb5aa8a34df1bd6d (diff) | |
| download | tts-audiobook-generator-6cfcd564c0684c52618235e6366f4a81c02b9a5b.tar.gz | |
slop refactor/dedup
Diffstat (limited to 'app/backends/probe.py')
| -rw-r--r-- | app/backends/probe.py | 21 |
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. |
