Merge pull request #41 from Cp0204/patch-1

GPT评价错误提示中止
This commit is contained in:
6dylan6 2023-06-27 21:59:05 +08:00 committed by GitHub
commit 808476ee92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -184,6 +184,10 @@ def generation_ai(pname, _class=0, _type=1, opts=None):
}
)
response_text = response.json()
if "error" in response_text:
print("\nOpenAI API 调用错误:\n", response_text["error"]["message"])
exit()
else:
return 5, response_text["choices"][0]["message"]["content"].strip()