Open maxchen2k opened 1 year ago
這個問題應該出在 openai 本身有些問題,請問目前多次嘗試下來問題依舊存在嗎?
目前問題仍會發生,不知如何查閱 INFO 這個物件內容?
2023-03-08 00:54:09 INFO chatgpt_logger -> U94fdb27e34200c86ad9d65fd71280849: 你懂股票嗎? U94fdb27e34200c86ad9d65fd71280849 [2023-03-08 00:54:40,171] 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 57, in handle_text_message response = chatgpt.get_response(user_id, text) File "/home/runner/ChatGPT-Line-Bot/src/chatgpt.py", line 12, in get_response response = self.model.chat_completion(self.memory.get(user_id)) File "/home/runner/ChatGPT-Line-Bot/src/models.py", line 20, in chat_completion response = openai.ChatCompletion.create( File "/home/runner/ChatGPT-Line-Bot/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/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/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/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/venv/lib/python3.10/site-packages/openai/api_requestor.py", line 679, in _interpret_response_line raise self.handle_error_response( openai.error.RateLimitError: That model is currently overloaded with other requests. You can retry your request, or contact us through our help center at help.openai.com if the error persists. (Please include the request ID 81029ad7ae47a72ea865e06648137121 in your message.)
我也是一直出現錯誤,但是打/imagine可以畫圖,打其他任何中文字都沒回應? 錯誤代碼如下? [2023-03-08 10:44:49,399] 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 10:44:49] "POST /callback HTTP/1.1" 500 -
我剛測試了一下,請把 OPENAI_MODEL_ENGINE 設為 gpt-3.5-turbo
gpt-3.5-turbo
還是一樣出現錯誤,無法收到回應? 2023-03-08 13:43:05 INFO chatgpt_logger -> U95df74dfee2e3e161b88159cf6813: HI U95df74dfee2e3e161b88159cf6813 [2023-03-08 13:43:05,842] 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: None is not of type 'string' - 'messages.0.content' 172.31.128.1 - - [08/Mar/2023 13:43:05] "POST /callback HTTP/1.1" 500 -
看錯誤訊息,感覺環境變數沒有設定成功唷,可以 print(os.getenv("OPENAI_MODEL_ENGINE"))
看看是不是 None 而非 gpt-3.5-turbo
簡單可以修改的方式是,這個 function 直接改成以下
def chat_completion(self, messages) -> str:
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages
)
return response
print(os.getenv("OPENAI_MODEL_ENGINE"))
輸入這行之後按下Enter沒反應耶?
我把function放到main.py裡面去了,好像還是一樣跳錯誤?謝謝
在某個特定 Line User 發過來的訊息會造成下列錯誤,請問是什麼原因?
2023-03-07 12:27:24 INFO chatgpt_logger -> U94fdb27e34200c86ad9d65fd71280849: 藍牙裝置跟手機連線時,由app偵測所顯示的信號強度可讀出兩裝置間的距離嗎? U94fdb27e34200c86ad9d65fd71280849 [2023-03-07 12:27:29,795] 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 57, in handle_text_message response = chatgpt.get_response(user_id, text) File "/home/runner/ChatGPT-Line-Bot/src/chatgpt.py", line 12, in get_response response = self.model.chat_completion(self.memory.get(user_id)) File "/home/runner/ChatGPT-Line-Bot/src/models.py", line 20, in chat_completion response = openai.ChatCompletion.create( File "/home/runner/ChatGPT-Line-Bot/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/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/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/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/venv/lib/python3.10/site-packages/openai/api_requestor.py", line 679, in _interpret_response_line raise self.handle_error_response( openai.error.APIError: Internal server error { "error": { "message": "Internal server error", "type": "auth_subrequest_error", "param": null, "code": "internal_error" } } 500 {'error': {'message': 'Internal server error', 'type': 'auth_subrequest_error', 'param': None, 'code': 'internal_error'}} {'Date': 'Tue, 07 Mar 2023 12:27:29 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '166', 'Connection': 'keep-alive', 'Vary': 'Origin', 'X-Request-Id': '3fa25b7a78e9cdb221712f37e280c83e', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains'}