From 7ca41449131af6dbc9ea79d802a25a07ce6be3ba Mon Sep 17 00:00:00 2001 From: yshtcn Date: Mon, 27 Jan 2025 18:40:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=B5=81=E5=BC=8F?= =?UTF-8?q?=E4=BC=A0=E8=BE=93=E7=9A=84=E8=B6=85=E6=97=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 移除流式传输的整体超时限制 2. 添加专门的超时错误处理 3. 避免与MODEL_TIMEOUT_SECONDS参数冲突 --- ollama_proxy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ollama_proxy.py b/ollama_proxy.py index 2c89c4e..3266cb8 100644 --- a/ollama_proxy.py +++ b/ollama_proxy.py @@ -190,11 +190,14 @@ async def proxy(request: Request, path: str): url=target_url, json=request_body, headers=headers, - timeout=timeout + timeout=None # 流式传输不设置整体超时 ) as response: async for line in response.aiter_lines(): if line.strip(): # 忽略空行 yield line.encode('utf-8') + b'\n' + except httpx.TimeoutError as e: + logger.error(f"流式传输超时: {str(e)}") + raise except Exception as e: logger.error(f"流式传输时发生错误: {str(e)}") raise