TheExplainthis / ChatGPT-Line-Bot

This is a repository that allows you to integrate ChatGPT into Line.
MIT License
1.53k stars 1.86k forks source link

console執行問題 #6

Open jim030784 opened 1 year ago

jim030784 commented 1 year ago

想請問為什麼在console端我這邊執行, 為何會出現這樣的錯誤訊息呢? line在執行後也無法回傳訊息 感謝。 1

jim030784 commented 1 year ago

2 當我在line傳訊息則會出現這樣的狀況, 感謝回應。

TheExplainthis commented 1 year ago

針對圖一,因為 /callback 沒有 GET 的 Method,所以直接打會錯誤唷! 針對圖二,截圖的下半部還有更多的錯誤訊息嗎?

maxchen2k commented 1 year ago

172.31.128.1 - - [06/Mar/2023 15:39:51] "POST /callback HTTP/1.1" 200 - [2023-03-06 15:39:51,911] ERROR in app: Exception on /callback [POST] Traceback (most recent call last): File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/flask/app.py", line 2528, in wsgi_app response = self.full_dispatch_request() File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "main.py", line 38, in callback handler.handle(body, signature) File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/linebot/webhook.py", line 259, in handle self.invoke_func(func, event, payload) File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/linebot/webhook.py", line 271, in __invoke_func func(event) File "main.py", line 60, in handle_text_message line_bot_api.reply_message( File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/linebot/api.py", line 113, in reply_message self._post( File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/linebot/api.py", line 1860, in _post self.check_error(response) File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/linebot/api.py", line 1896, in __check_error raise LineBotApiError( linebot.exceptions.LineBotApiError: LineBotApiError: status_code=400, request_id=3d6769f8-8427-494c-a636-d35d03a81765, error_response={"details": [], "message": "Invalid reply token"}, headers={'Content-Type': 'application/json', 'Server': 'envoy', 'x-content-type-options': 'nosniff', 'x-frame-options': 'DENY', 'x-line-request-id': '3d6769f8-8427-494c-a636-d35d03a81765', 'x-xss-protection': '1; mode=block', 'Content-Length': '33', 'Expires': 'Mon, 06 Mar 2023 15:39:51 GMT', 'Cache-Control': 'max-age=0, no-cache, no-store', 'Pragma': 'no-cache', 'Date': 'Mon, 06 Mar 2023 15:39:51 GMT', 'Connection': 'close'}

jim030784 commented 1 year ago

圖一的部分,我在line develop有加上callback,但有時會出現這樣的訊息耶... 另外附圖 1

TheExplainthis commented 1 year ago

172.31.128.1 - - [06/Mar/2023 15:39:51] "POST /callback HTTP/1.1" 200 - [2023-03-06 15:39:51,911] ERROR in app: Exception on /callback [POST] Traceback (most recent call last): File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/flask/app.py", line 2528, in wsgi_app response = self.full_dispatch_request() File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "main.py", line 38, in callback handler.handle(body, signature) File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/linebot/webhook.py", line 259, in handle self.invoke_func(func, event, payload) File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/linebot/webhook.py", line 271, in __invoke_func func(event) File "main.py", line 60, in handle_text_message line_bot_api.reply_message( File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/linebot/api.py", line 113, in reply_message self._post( File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/linebot/api.py", line 1860, in _post self.check_error(response) File "/home/runner/ChatGPT-Line-Bot/venv/lib/python3.10/site-packages/linebot/api.py", line 1896, in __check_error raise LineBotApiError( linebot.exceptions.LineBotApiError: LineBotApiError: status_code=400, request_id=3d6769f8-8427-494c-a636-d35d03a81765, error_response={"details": [], "message": "Invalid reply token"}, headers={'Content-Type': 'application/json', 'Server': 'envoy', 'x-content-type-options': 'nosniff', 'x-frame-options': 'DENY', 'x-line-request-id': '3d6769f8-8427-494c-a636-d35d03a81765', 'x-xss-protection': '1; mode=block', 'Content-Length': '33', 'Expires': 'Mon, 06 Mar 2023 15:39:51 GMT', 'Cache-Control': 'max-age=0, no-cache, no-store', 'Pragma': 'no-cache', 'Date': 'Mon, 06 Mar 2023 15:39:51 GMT', 'Connection': 'close'}

可以嘗試看看這個人的解法 https://github.com/line/line-bot-sdk-python/issues/37

TheExplainthis commented 1 year ago

圖一的部分,我在line develop有加上callback,但有時會出現這樣的訊息耶... 另外附圖 1

針對這個問題,可以試著更新 openai 的版本

pip install --upgrade openai
FishBowl00003 commented 1 year ago

圖一的部分,我在line develop有加上callback,但有時會出現這樣的訊息耶... 另外附圖 1

針對這個問題,可以試著更新 openai 的版本

pip install --upgrade openai

還是一樣會跳錯誤 2023-03-08 11:29:31 INFO chatgpt_logger -> U93df74dfee2e3e161b88159cf6813: 哈哈 U93df74dfee2e3e161b88159cf6813 [2023-03-08 11:29:32,262] ERROR in app: Exception on /callback [POST] Traceback (most recent call last): File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/flask/app.py", line 2528, in wsgi_app response = self.full_dispatch_request() File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/flask/app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(*view_args) File "main.py", line 38, in callback handler.handle(body, signature) File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/linebot/webhook.py", line 259, in handle self.__invoke_func(func, event, payload) File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/linebot/webhook.py", line 271, in __invoke_func func(event) File "main.py", line 57, in handle_text_message response = chatgpt.get_response(user_id, text) File "/home/runner/ChatGPT-Line-Bot-1/src/chatgpt.py", line 12, in get_response response = self.model.chat_completion(self.memory.get(user_id)) File "/home/runner/ChatGPT-Line-Bot-1/src/models.py", line 20, in chat_completion response = openai.ChatCompletion.create( File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/openai/api_resources/chat_completion.py", line 25, in create return super().create(args, **kwargs) File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/openai/api_resources/abstract/engine_apiresource.py", line 153, in create response, , api_key = requestor.request( File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/openai/api_requestor.py", line 226, in request resp, got_stream = self._interpret_response(result, stream) File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/openai/api_requestor.py", line 619, in _interpret_response self._interpret_response_line( File "/home/runner/ChatGPT-Line-Bot-1/venv/lib/python3.10/site-packages/openai/api_requestor.py", line 679, in _interpret_response_line raise self.handle_error_response( openai.error.InvalidRequestError: Invalid URL (POST /v1/chat/completions) 172.31.128.1 - - [08/Mar/2023 11:29:32] "POST /callback HTTP/1.1" 500 - pip install --upgrade openai 172.31.128.1 - - [08/Mar/2023 11:30:11] "GET / HTTP/1.1" 200 - 172.31.128.1 - - [08/Mar/2023 11:30:22] "POST /callback HTTP/1.1" 200 -