diff --git a/src/parallax/p2p/server.py b/src/parallax/p2p/server.py index 77d0e00b..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=20 * 60 * 60) 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,14 +174,14 @@ def chat_completion( for chunk in response.iter_bytes(): if chunk: yield chunk - else: - with httpx.Client(timeout=20 * 60 * 60) as client: + else: response = client.post( f"http://localhost:{self.http_port}/v1/chat/completions", json=request ).json() yield json.dumps(response).encode() except Exception as e: logger.exception(f"Error in chat completion: {e}") + yield b"internal server error" class GradientServer: