From eea060af3c10731110fffb87e70cdb58422604f6 Mon Sep 17 00:00:00 2001 From: gufengc Date: Sat, 11 Oct 2025 15:56:56 +0800 Subject: [PATCH 1/5] fix(http): fix localhost bypass proxy --- src/parallax/p2p/server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parallax/p2p/server.py b/src/parallax/p2p/server.py index 77d0e00b..7429ac94 100644 --- a/src/parallax/p2p/server.py +++ b/src/parallax/p2p/server.py @@ -165,7 +165,7 @@ def chat_completion( logger.debug(f"Chat completion request: {request}, type: {type(request)}") try: if request.get("stream", False): - with httpx.Client(timeout=20 * 60 * 60) as client: + with httpx.Client(timeout=10 * 60, proxy={}) as client: with client.stream( "POST", f"http://localhost:{self.http_port}/v1/chat/completions", @@ -175,7 +175,7 @@ def chat_completion( if chunk: yield chunk else: - with httpx.Client(timeout=20 * 60 * 60) as client: + with httpx.Client(timeout=10 * 60, proxy={}) as client: response = client.post( f"http://localhost:{self.http_port}/v1/chat/completions", json=request ).json() @@ -611,7 +611,7 @@ def get_node_info(self, is_update: bool = False): "node_id": self.lattica.peer_id(), "hardware": detect_node_hardware(self.lattica.peer_id()), "kv_cache_ratio": 0.25, - "param_hosting_ratio": 0.65, + "param_hosting_ratio": 0.01, "max_concurrent_requests": self.max_batch_size, "max_sequence_length": ( 1024 if self.max_sequence_length is None else self.max_sequence_length From 3e769101165728146c385b096cab46441d0eaac5 Mon Sep 17 00:00:00 2001 From: gufengc Date: Sat, 11 Oct 2025 15:59:45 +0800 Subject: [PATCH 2/5] update --- src/parallax/p2p/server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parallax/p2p/server.py b/src/parallax/p2p/server.py index 7429ac94..dd1f1cea 100644 --- a/src/parallax/p2p/server.py +++ b/src/parallax/p2p/server.py @@ -182,6 +182,7 @@ def chat_completion( yield json.dumps(response).encode() except Exception as e: logger.exception(f"Error in chat completion: {e}") + yield b"internal server error" class GradientServer: From 277503ddae85352748328a76b4078475a9bf6111 Mon Sep 17 00:00:00 2001 From: gufengc Date: Sat, 11 Oct 2025 16:09:35 +0800 Subject: [PATCH 3/5] update --- src/parallax/p2p/server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parallax/p2p/server.py b/src/parallax/p2p/server.py index dd1f1cea..b9e161ce 100644 --- a/src/parallax/p2p/server.py +++ b/src/parallax/p2p/server.py @@ -165,7 +165,7 @@ def chat_completion( logger.debug(f"Chat completion request: {request}, type: {type(request)}") try: if request.get("stream", False): - with httpx.Client(timeout=10 * 60, proxy={}) as client: + with httpx.Client(timeout=10 * 60, proxies=None, trust_env=False) as client: with client.stream( "POST", f"http://localhost:{self.http_port}/v1/chat/completions", @@ -175,7 +175,7 @@ def chat_completion( if chunk: yield chunk else: - with httpx.Client(timeout=10 * 60, proxy={}) as client: + with httpx.Client(timeout=10 * 60, proxies=None, trust_env=False) as client: response = client.post( f"http://localhost:{self.http_port}/v1/chat/completions", json=request ).json() @@ -612,7 +612,7 @@ def get_node_info(self, is_update: bool = False): "node_id": self.lattica.peer_id(), "hardware": detect_node_hardware(self.lattica.peer_id()), "kv_cache_ratio": 0.25, - "param_hosting_ratio": 0.01, + "param_hosting_ratio": 0.65, "max_concurrent_requests": self.max_batch_size, "max_sequence_length": ( 1024 if self.max_sequence_length is None else self.max_sequence_length From dc9956d1df4f7a0212357955a82c4bead69885a6 Mon Sep 17 00:00:00 2001 From: gufengc Date: Sat, 11 Oct 2025 16:13:35 +0800 Subject: [PATCH 4/5] update --- src/parallax/p2p/server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parallax/p2p/server.py b/src/parallax/p2p/server.py index b9e161ce..cc5fb73a 100644 --- a/src/parallax/p2p/server.py +++ b/src/parallax/p2p/server.py @@ -165,7 +165,7 @@ def chat_completion( logger.debug(f"Chat completion request: {request}, type: {type(request)}") try: if request.get("stream", False): - with httpx.Client(timeout=10 * 60, proxies=None, trust_env=False) as client: + with httpx.Client(timeout=10 * 60, proxy=None, trust_env=False) as client: with client.stream( "POST", f"http://localhost:{self.http_port}/v1/chat/completions", @@ -175,7 +175,7 @@ def chat_completion( if chunk: yield chunk else: - with httpx.Client(timeout=10 * 60, proxies=None, trust_env=False) as client: + with httpx.Client(timeout=10 * 60, proxy=None, trust_env=False) as client: response = client.post( f"http://localhost:{self.http_port}/v1/chat/completions", json=request ).json() From 13216181432ccea4a295814981abfb4f43064d2c Mon Sep 17 00:00:00 2001 From: gufengc Date: Sat, 11 Oct 2025 17:03:37 +0800 Subject: [PATCH 5/5] update --- src/parallax/p2p/server.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/parallax/p2p/server.py b/src/parallax/p2p/server.py index cc5fb73a..772a8a77 100644 --- a/src/parallax/p2p/server.py +++ b/src/parallax/p2p/server.py @@ -164,8 +164,8 @@ def chat_completion( """Handle chat completion request""" logger.debug(f"Chat completion request: {request}, type: {type(request)}") try: - if request.get("stream", False): - with httpx.Client(timeout=10 * 60, proxy=None, trust_env=False) as client: + with httpx.Client(timeout=10 * 60, proxy=None, trust_env=False) as client: + if request.get("stream", False): with client.stream( "POST", f"http://localhost:{self.http_port}/v1/chat/completions", @@ -174,8 +174,7 @@ def chat_completion( for chunk in response.iter_bytes(): if chunk: yield chunk - else: - with httpx.Client(timeout=10 * 60, proxy=None, trust_env=False) as client: + else: response = client.post( f"http://localhost:{self.http_port}/v1/chat/completions", json=request ).json()