TheExplainthis / ChatGPT-Discord-Bot

This is a repository that allows you to integrate ChatGPT into Discord.
MIT License
569 stars 1.19k forks source link

ChatBot /chat Issue #9

Open swarfte opened 1 year ago

swarfte commented 1 year ago

最近通過/chat 調用時常出現這個問題, 請問有甚麼方法可以解決?

2023-03-24 01:13:05 WARNING  discord.gateway Shard ID None heartbeat blocked for more than 200 seconds.
Loop thread traceback (most recent call last):
  File "/home/swarfte/Computer/server/workSpace/chatgpt/ChatGPT-Discord-Bot/main.py", line 61, in <module>
    run()
  File "/home/swarfte/Computer/server/workSpace/chatgpt/ChatGPT-Discord-Bot/main.py", line 56, in run
    client.run(os.getenv('DISCORD_TOKEN'))
  File "/home/swarfte/.local/lib/python3.10/site-packages/discord/client.py", line 828, in run
    asyncio.run(runner())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 633, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 600, in run_forever
    self._run_once()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 1896, in _run_once
    handle._run()
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/swarfte/.local/lib/python3.10/site-packages/discord/app_commands/tree.py", line 1091, in wrapper
    await self._call(interaction)
  File "/home/swarfte/.local/lib/python3.10/site-packages/discord/app_commands/tree.py", line 1242, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/home/swarfte/.local/lib/python3.10/site-packages/discord/app_commands/commands.py", line 887, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "/home/swarfte/.local/lib/python3.10/site-packages/discord/app_commands/commands.py", line 862, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "/home/swarfte/Computer/server/workSpace/chatgpt/ChatGPT-Discord-Bot/main.py", line 33, in chat
    receive = chatgpt.get_response(user_id, message)
  File "/home/swarfte/Computer/server/workSpace/chatgpt/ChatGPT-Discord-Bot/src/chatgpt.py", line 12, in get_response
    response = self.model.chat_completion(self.memory.get(user_id))
  File "/home/swarfte/Computer/server/workSpace/chatgpt/ChatGPT-Discord-Bot/src/models.py", line 20, in chat_completion
    response = openai.ChatCompletion.create(
  File "/home/swarfte/.local/lib/python3.10/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/home/swarfte/.local/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "/home/swarfte/.local/lib/python3.10/site-packages/openai/api_requestor.py", line 216, in request
    result = self.request_raw(
  File "/home/swarfte/.local/lib/python3.10/site-packages/openai/api_requestor.py", line 516, in request_raw
    result = _thread_context.session.request(
  File "/home/swarfte/.local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/swarfte/.local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/home/swarfte/.local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 440, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.10/http/client.py", line 1374, in getresponse
    response.begin()
  File "/usr/lib/python3.10/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.10/http/client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.10/socket.py", line 705, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.10/ssl.py", line 1274, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.10/ssl.py", line 1130, in read
    return self._sslobj.read(len, buffer)