mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-15 14:22:43 +00:00
fix(agent): probe localhost via IPv4 for LM Studio detection
This commit is contained in:
parent
ba2d8b36c1
commit
7d324b0e47
2 changed files with 9 additions and 8 deletions
|
|
@ -631,16 +631,17 @@ def detect_local_server_type(base_url: str, api_key: str = "") -> Optional[str]:
|
|||
import httpx
|
||||
|
||||
normalized = _normalize_base_url(base_url)
|
||||
|
||||
# Resolve localhost to IPv4 to avoid 2s IPv6 timeout on Windows dual-stack.
|
||||
normalized = normalized.replace("://localhost:", "://127.0.0.1:")
|
||||
normalized = normalized.replace("://localhost/", "://127.0.0.1/")
|
||||
if normalized.endswith("://localhost"):
|
||||
normalized = normalized[:-len("localhost")] + "127.0.0.1"
|
||||
|
||||
server_url = normalized
|
||||
if server_url.endswith("/v1"):
|
||||
server_url = server_url[:-3]
|
||||
lmstudio_url = _lmstudio_server_root(base_url)
|
||||
|
||||
# Resolve localhost to IPv4 to avoid 2s IPv6 timeout on Windows dual-stack.
|
||||
server_url = server_url.replace("://localhost:", "://127.0.0.1:")
|
||||
server_url = server_url.replace("://localhost/", "://127.0.0.1/")
|
||||
if server_url.endswith("://localhost"):
|
||||
server_url = server_url[:-len("localhost")] + "127.0.0.1"
|
||||
lmstudio_url = _lmstudio_server_root(normalized)
|
||||
|
||||
headers = _auth_headers(api_key)
|
||||
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ class TestDetectLocalServerTypeAuth:
|
|||
result = detect_local_server_type("http://localhost:1234/api/v1")
|
||||
|
||||
assert result == "lm-studio"
|
||||
assert client_mock.get.call_args_list[0].args[0] == "http://localhost:1234/api/v1/models"
|
||||
assert client_mock.get.call_args_list[0].args[0] == "http://127.0.0.1:1234/api/v1/models"
|
||||
|
||||
|
||||
class TestDetectLocalServerTypeLocalhostIPv4:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue