baidubce / bce-qianfan-sdk

Provide best practices for LMOps, as well as elegant and convenient access to the features of the Qianfan MaaS Platform. (提供大模型工具链最佳实践,以及优雅且便捷地访问千帆大模型平台)
https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html
Apache License 2.0
307 stars 48 forks source link

openai adapter 的接口报错 #784

Open kbaicai opened 1 week ago

kbaicai commented 1 week ago

System Info

[WARNING][2024-09-05 10:22:42.189] base.py:844 [t:139402731568000]: This key extra_parameters does not seem to be a parameter that the model ERNIE-3.5-8K will accept ERROR: Exception in ASGI application Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/client_proto.py", line 94, in connection_lost uncompleted = self._parser.feed_eof() File "aiohttp/_http_parser.pyx", line 513, in aiohttp._http_parser.HttpParser.feed_eof aiohttp.http_exceptions.TransferEncodingError: 400, message: Not enough data for satisfy transfer length header.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi result = await app( # type: ignore[func-returns-value] File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in call return await self.app(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in call await super().call(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 113, in call await self.middleware_stack(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in call raise exc File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in call await self.app(scope, receive, _send) File "/usr/local/lib/python3.10/site-packages/starlette/middleware/cors.py", line 85, in call await self.app(scope, receive, send) File "/usr/local/lib/python3.10/site-packages/starlette/middleware/base.py", line 185, in call with collapse_excgroups(): File "/usr/local/lib/python3.10/contextlib.py", line 153, in exit self.gen.throw(typ, value, traceback) File "/usr/local/lib/python3.10/site-packages/starlette/_utils.py", line 83, in collapse_excgroups raise exc File "/usr/local/lib/python3.10/site-packages/starlette/responses.py", line 253, in wrap await func() File "/usr/local/lib/python3.10/site-packages/starlette/responses.py", line 242, in stream_response async for chunk in self.body_iterator: File "/usr/local/lib/python3.10/site-packages/qianfan/common/client/openai_adapter.py", line 85, in stream async for data in resp: File "/usr/local/lib/python3.10/site-packages/qianfan/extensions/openai/adapter.py", line 467, in _chat_stream async for i, res in results: File "/usr/local/lib/python3.10/site-packages/qianfan/extensions/openai/adapter.py", line 63, in merged raise next_item File "/usr/local/lib/python3.10/site-packages/qianfan/extensions/openai/adapter.py", line 45, in drain async for item in aiter: File "/usr/local/lib/python3.10/site-packages/qianfan/extensions/openai/adapter.py", line 461, in task async for res in res_stream: File "/usr/local/lib/python3.10/site-packages/qianfan/resources/requestor/openapi_requestor.py", line 533, in _async_generator_wrapper async for res in generator: File "/usr/local/lib/python3.10/site-packages/qianfan/resources/requestor/openapi_requestor.py", line 394, in _async_compensate_token_usage_stream async for res in resp: File "/usr/local/lib/python3.10/site-packages/qianfan/resources/requestor/base.py", line 271, in iter async for r in resp: File "/usr/local/lib/python3.10/site-packages/qianfan/resources/requestor/openapi_requestor.py", line 219, in iter async for body, resp in responses: File "/usr/local/lib/python3.10/site-packages/qianfan/resources/http_client.py", line 129, in arequest_stream async for line in resp.content: File "/usr/local/lib/python3.10/site-packages/aiohttp/streams.py", line 50, in anext rv = await self.read_func() File "/usr/local/lib/python3.10/site-packages/aiohttp/streams.py", line 317, in readline return await self.readuntil() File "/usr/local/lib/python3.10/site-packages/aiohttp/streams.py", line 351, in readuntil await self._wait("readuntil") File "/usr/local/lib/python3.10/site-packages/aiohttp/streams.py", line 312, in _wait await waiter aiohttp.client_exceptions.ClientPayloadError: Response payload is not completed: <TransferEncodingError: 400, message='Not enough data for satisfy transfer length header.'>. ConnectionResetError(104, 'Connection reset by peer')

Reproduction

版本是 0.3.15

kbaicai commented 1 week ago

看错了,版本是0.4.6

Dobiichi-Origami commented 1 week ago

麻烦提供下可稳定复现的代码