🐛Fix: 增加 AI 返回错误时的特判
This commit is contained in:
@@ -26,7 +26,9 @@ public class AIService {
|
|||||||
.header("Authorization", "Bearer " + AIConstant.AI_TOKEN)
|
.header("Authorization", "Bearer " + AIConstant.AI_TOKEN)
|
||||||
.body(jsonBody)
|
.body(jsonBody)
|
||||||
.execute();
|
.execute();
|
||||||
|
if (response.getStatus() != 200) {
|
||||||
|
return AIConstant.DEFAULT_ERROR_RESPONSE;
|
||||||
|
}
|
||||||
JSONObject jsonResponse = JSONUtil.parseObj(response.body());
|
JSONObject jsonResponse = JSONUtil.parseObj(response.body());
|
||||||
return jsonResponse.getJSONArray("choices").getJSONObject(0).getJSONObject("message").getStr("content");
|
return jsonResponse.getJSONArray("choices").getJSONObject(0).getJSONObject("message").getStr("content");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user