From 2e3727e9cf8a4cb37cbfcda6627ac6c2d9b095f1 Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Mon, 26 Jun 2023 13:31:32 +0800 Subject: [PATCH] =?UTF-8?q?GPT=E8=AF=84=E4=BB=B7=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=B8=AD=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_comment.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jd_comment.py b/jd_comment.py index 0337232..ec62075 100644 --- a/jd_comment.py +++ b/jd_comment.py @@ -184,7 +184,11 @@ def generation_ai(pname, _class=0, _type=1, opts=None): } ) response_text = response.json() - return 5, response_text["choices"][0]["message"]["content"].strip() + if "error" in response_text: + print("\nOpenAI API 调用错误:\n", response_text["error"]["message"]) + exit() + else: + return 5, response_text["choices"][0]["message"]["content"].strip() # 查询全部评价