Closed onenov closed 1 year ago
添加NGINX反代规则解决了
# 不缓存,支持流式输出
proxy_cache off; # 关闭缓存
proxy_buffering off; # 关闭代理缓冲
tcp_nopush on; # 开启TCP NOPUSH选项,禁止Nagle算法
tcp_nodelay on; # 开启TCP NODELAY选项,禁止延迟ACK算法
keepalive_timeout 300; # 设定keep-alive超时时间为65秒
但是在发长文本出现下面这个错误::
INFO: 172.17.0.1:40322 - "POST /v1/chat/completions?path=v1&path=chat&path=completions HTTP/1.1" 200 OK
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/anyio/streams/tls.py", line 130, in _call_sslobject_method
result = func(*args)
File "/usr/local/lib/python3.9/ssl.py", line 889, in read
v = self._sslobj.read(len)
ssl.SSLWantReadError: The operation did not complete (read) (_ssl.c:2633)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 34, in read
return await self._stream.receive(max_bytes=max_bytes)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/anyio/streams/tls.py", line 195, in receive
data = await self._call_sslobject_method(self._ssl_object.read, max_bytes)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/anyio/streams/tls.py", line 137, in _call_sslobject_method
data = await self.transport_stream.receive()
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 1265, in receive
await self._protocol.read_event.wait()
File "/usr/local/lib/python3.9/asyncio/locks.py", line 226, in wait
await fut
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
yield
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 36, in read
return b""
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/anyio/_core/_tasks.py", line 118, in __exit__
raise TimeoutError
TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
yield
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request
raise exc
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
response = await connection.handle_async_request(request)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
return await self._connection.handle_async_request(request)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/_async/http11.py", line 116, in handle_async_request
raise exc
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/_async/http11.py", line 95, in handle_async_request
) = await self._receive_response_headers(**kwargs)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/_async/http11.py", line 159, in _receive_response_headers
event = await self._receive_event(timeout=timeout)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/_async/http11.py", line 195, in _receive_event
data = await self._network_stream.read(
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 36, in read
return b""
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc)
httpcore.ReadTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 428, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/fastapi/applications.py", line 276, in __call__
await super().__call__(scope, receive, send)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/applications.py", line 122, in __call__
await self.middleware_stack(scope, receive, send)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/middleware/cors.py", line 84, in __call__
await self.app(scope, receive, send)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
raise e
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/routing.py", line 718, in __call__
await route.handle(scope, receive, send)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/routing.py", line 69, in app
await response(scope, receive, send)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/responses.py", line 277, in __call__
await wrap(partial(self.listen_for_disconnect, receive))
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 662, in __aexit__
raise exceptions[0]
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/responses.py", line 273, in wrap
await func()
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/starlette/responses.py", line 262, in stream_response
async for chunk in self.body_iterator:
File "/app/claude_to_chatgpt/app.py", line 39, in generate
async for response in adapter.chat(request):
File "/app/claude_to_chatgpt/adapter.py", line 150, in chat
async with client.stream(
File "/usr/local/lib/python3.9/contextlib.py", line 181, in __aenter__
return await self.gen.__anext__()
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpx/_client.py", line 1573, in stream
response = await self.send(
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpx/_client.py", line 1617, in send
response = await self._send_handling_auth(
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpx/_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/root/.cache/pypoetry/virtualenvs/claude-to-chatgpt-9TtSrW0h-py3.9/lib/python3.9/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadTimeout
我自己是用的 Docker 版本好像没出问题,请问你用的是自己编译的镜像吗,另外是否有其它反向代理和网络转发之类的,可以去掉这些层试一下
Docker 部署似乎不支持流式响应,我使用的是Yidadaa/ChatGPT-Next-Web