Zero6992 / chatGPT-discord-bot

Integrate ChatGPT into your own discord bot
GNU General Public License v2.0
2.66k stars 699 forks source link

Illegal header value b'Bearer ' #422

Closed hypersmc closed 8 months ago

hypersmc commented 1 year ago

2023-06-14 11:40:17 ERROR src.aclient -> Error while sending message: Illegal header value b'Bearer ' Traceback (most recent call last): File "/home/container/.local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions yield File "/home/container/.local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 129, in _send_request_headers event = h11.Request( File "/home/container/.local/lib/python3.9/site-packages/h11/_events.py", line 96, in init self, "headers", normalize_and_validate(headers, _parsed=_parsed) File "/home/container/.local/lib/python3.9/site-packages/h11/_headers.py", line 164, in normalize_and_validate validate(_field_value_re, value, "Illegal header value {!r}", value) File "/home/container/.local/lib/python3.9/site-packages/h11/_util.py", line 91, in validate raise LocalProtocolError(msg) h11._util.LocalProtocolError: Illegal header value b'Bearer ' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/container/.local/lib/python3.9/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions yield File "/home/container/.local/lib/python3.9/site-packages/httpx/_transports/default.py", line 353, in handle_async_request resp = await self._pool.handle_async_request(req) File "/home/container/.local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 261, in handle_async_request raise exc File "/home/container/.local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 245, in handle_async_request response = await connection.handle_async_request(request) File "/home/container/.local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 96, in handle_async_request return await self._connection.handle_async_request(request) File "/home/container/.local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 120, in handle_async_request raise exc File "/home/container/.local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 88, in handle_async_request await self._send_request_headers(**kwargs) File "/home/container/.local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 129, in _send_request_headers event = h11.Request( File "/usr/local/lib/python3.9/contextlib.py", line 137, in exit self.gen.throw(typ, value, traceback) File "/home/container/.local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc httpcore.LocalProtocolError: Illegal header value b'Bearer ' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/container/src/aclient.py", line 109, in send_message response = f"{response}{await responses.unofficial_handle_response(user_message, self)}" File "/home/container/src/responses.py", line 14, in unofficial_handle_response async for response in client.chatbot.ask(message): File "/home/container/.local/lib/python3.9/site-packages/revChatGPT/V1.py", line 980, in ask async for msg in self.post_messages( File "/home/container/.local/lib/python3.9/site-packages/revChatGPT/V1.py", line 933, in post_messages async for msg in self.send_request( File "/home/container/.local/lib/python3.9/site-packages/revChatGPT/V1.py", line 811, in __send_request async with self.session.stream( File "/usr/local/lib/python3.9/contextlib.py", line 181, in aenter return await self.gen.anext__() File "/home/container/.local/lib/python3.9/site-packages/httpx/_client.py", line 1573, in stream response = await self.send( File "/home/container/.local/lib/python3.9/site-packages/httpx/_client.py", line 1617, in send response = await self._send_handling_auth( File "/home/container/.local/lib/python3.9/site-packages/httpx/_client.py", line 1645, in _send_handling_auth response = await self._send_handling_redirects( File "/home/container/.local/lib/python3.9/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects response = await self._send_single_request(request) File "/home/container/.local/lib/python3.9/site-packages/httpx/_client.py", line 1719, in _send_single_request response = await transport.handle_async_request(request) File "/home/container/.local/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 "/home/container/.local/lib/python3.9/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.LocalProtocolError: Illegal header value b'Bearer '

I'm using Python 3.9 trying to use the unofficial version

helsan74 commented 1 year ago

Same issue here with version 1.6.1

a3lita commented 10 months ago

Same issue. Did you ever solve this?

TashaSkyUp commented 10 months ago

Check to see that your openai env keys are set correctly. I had this error when a newline character had snuck into my key at the end

datlife commented 10 months ago

Check if your api_key is set properly. Mine was empty