mirror of
https://github.com/yshtcn/OllamaProxy.git
synced 2025-12-17 03:40:22 +08:00
fix: 优化流式传输的超时处理
1. 移除流式传输的整体超时限制 2. 添加专门的超时错误处理 3. 避免与MODEL_TIMEOUT_SECONDS参数冲突
This commit is contained in:
parent
a40fbadf7b
commit
7ca4144913
@ -190,11 +190,14 @@ async def proxy(request: Request, path: str):
|
|||||||
url=target_url,
|
url=target_url,
|
||||||
json=request_body,
|
json=request_body,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
timeout=timeout
|
timeout=None # 流式传输不设置整体超时
|
||||||
) as response:
|
) as response:
|
||||||
async for line in response.aiter_lines():
|
async for line in response.aiter_lines():
|
||||||
if line.strip(): # 忽略空行
|
if line.strip(): # 忽略空行
|
||||||
yield line.encode('utf-8') + b'\n'
|
yield line.encode('utf-8') + b'\n'
|
||||||
|
except httpx.TimeoutError as e:
|
||||||
|
logger.error(f"流式传输超时: {str(e)}")
|
||||||
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"流式传输时发生错误: {str(e)}")
|
logger.error(f"流式传输时发生错误: {str(e)}")
|
||||||
raise
|
raise
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user