weaviate / Verba

Retrieval Augmented Generation (RAG) chatbot powered by Weaviate
BSD 3-Clause "New" or "Revised" License
4.76k stars 488 forks source link

WebSocket Error: 'finish_reason' #194

Open NeverOccurs opened 1 month ago

NeverOccurs commented 1 month ago

Description

I am using docker. Calling the API and generate an answer would cause the websocket to go offline.

Info in Chrome

Unchecked runtime.lastError: The message port closed before a response was received. localhost/:1 Unchecked runtime.lastError: The message port closed before a response was received. localhost/:1 Unchecked runtime.lastError: The message port closed before a response was received. localhost/:1 Unchecked runtime.lastError: The message port closed before a response was received. localhost/:1 Unchecked runtime.lastError: The message port closed before a response was received. localhost/:1 Unchecked runtime.lastError: The message port closed before a response was received. localhost/:1 Unchecked runtime.lastError: The message port closed before a response was received. page-9ca43b0df0af136b.js:1 WebSocket connection closed cleanly, code=1005, reason= page-9ca43b0df0af136b.js:1 WebSocket connection opened to ws://localhost:8000/ws/generate_stream 23-5e3f67a9ac794630.js:1 WebSocket connection died window.console.error @ 23-5e3f67a9ac794630.js:1

Info in Docker

ERROR: Exception in ASGI application verba-1 | Traceback (most recent call last): verba-1 | File "/Verba/goldenverba/server/api.py", line 179, in websocket_generate_stream verba-1 | async for chunk in manager.generate_stream_answer( verba-1 | File "/Verba/goldenverba/verba_manager.py", line 662, in generate_stream_answer verba-1 | async for result in self.generator_manager.generators[ verba-1 | File "/Verba/goldenverba/components/generation/GPT4Generator.py", line 82, in generate_stream verba-1 | "finish_reason": chunk["choices"][0]["finish_reason"], verba-1 | ~~~~~~~^^^^^^^^^^^^^^^^^ verba-1 | KeyError: 'finish_reason' verba-1 | verba-1 | During handling of the above exception, another exception occurred: verba-1 | verba-1 | Traceback (most recent call last): verba-1 | File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 240, in run_asgi verba-1 | result = await self.app(self.scope, self.asgi_receive, self.asgi_send) verba-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ verba-1 | File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in call verba-1 | return await self.app(scope, receive, send) verba-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ verba-1 | File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 292, in call verba-1 | await super().call(scope, receive, send) verba-1 | File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 122, in call verba-1 | await self.middleware_stack(scope, receive, send) verba-1 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 149, in call verba-1 | await self.app(scope, receive, send) verba-1 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 75, in call verba-1 | await self.app(scope, receive, send) verba-1 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in call verba-1 | raise exc verba-1 | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in call verba-1 | await self.app(scope, receive, sender) verba-1 | File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in call verba-1 | raise e verba-1 | File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in call verba-1 | await self.app(scope, receive, send) verba-1 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 718, in call verba-1 | await route.handle(scope, receive, send) verba-1 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 341, in handle verba-1 | await self.app(scope, receive, send) verba-1 | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 82, in app verba-1 | await func(session) verba-1 | File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 324, in app verba-1 | await dependant.call(values) verba-1 | File "/Verba/goldenverba/server/api.py", line 193, in websocket_generate_stream verba-1 | await websocket.send_json( verba-1 | File "/usr/local/lib/python3.11/site-packages/starlette/websockets.py", line 171, in send_json verba-1 | text = json.dumps(data, separators=(",", ":")) verba-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ verba-1 | File "/usr/local/lib/python3.11/json/init.py", line 238, in dumps verba-1 | kw).encode(obj) verba-1 | ^^^^^^^^^^^ verba-1 | File "/usr/local/lib/python3.11/json/encoder.py", line 200, in encode verba-1 | chunks = self.iterencode(o, _one_shot=True) verba-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ verba-1 | File "/usr/local/lib/python3.11/json/encoder.py", line 258, in iterencode verba-1 | return _iterencode(o, 0) verba-1 | ^^^^^^^^^^^^^^^^^ verba-1 | File "/usr/local/lib/python3.11/json/encoder.py", line 180, in default verba-1 | raise TypeError(f'Object of type {o.class.name} ' verba-1 | TypeError: Object of type KeyError is not JSON serializable verba-1 | INFO: connection closed verba-1 | ✘ WebSocket Error: 'finish_reason'

thomashacker commented 1 month ago

It seems like the payload sent by OpenAI does not contain the finish_reason key. Did you check if your OpenAI keys has access to GPT4 and has enough credits?

NeverOccurs commented 3 weeks ago

It seems like the payload sent by OpenAI does not contain the finish_reason key. Did you check if your OpenAI keys has access to GPT4 and has enough credits?

Yes, seems my credit has been deducted but can't get a decent response. I tried around for sometime but getting 405 Not Allowed error now. Still investigating why.

13777469818 commented 3 weeks ago

unsubscribe

商凯尔(鬼谷子) | 咪咕数字传媒有限公司 | 系统研发部(数据应用中心) 13777469818| @.***| 杭州市西湖区文二西路780号西溪银座A座

From: TuyoSera Date: 2024-06-03 08:17 To: weaviate/Verba CC: Subscribed Subject: Re: [weaviate/Verba] WebSocket Error: 'finish_reason' (Issue #194) It seems like the payload sent by OpenAI does not contain the finish_reason key. Did you check if your OpenAI keys has access to GPT4 and has enough credits? Yes, seems my credit has been deducted but can't get a decent response. I tried around for sometime but getting 405 Not Allowed error now. Still investigating why. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>