|
|
@@ -1,5 +1,6 @@
|
|
|
package com.cyksj.web.controller.mirror;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
@@ -32,6 +33,7 @@ import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.Date;
|
|
|
import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
@@ -144,29 +146,26 @@ public class MirrorController {
|
|
|
//text-davinci-002-render-sha 3.5
|
|
|
ConversationLimitResponse conversationLimitResponse = chatGptAccountService.conversationLimit(userToken, conversationRequest.getModel(), conversationRequest.getCarId(), user, isCar);
|
|
|
|
|
|
-
|
|
|
if (conversationLimitResponse.isLimited()) {
|
|
|
- response.setStatus(429);
|
|
|
+ response.setStatus(400);
|
|
|
//String json = "{\"detail\":{\"message\":\"您的账号已达到GPT-4的使用上限。您现在可以继续使用默认模型,或者重试在\",\"code\":\"model_cap_exceeded\",\"clears_in\":2687}}";
|
|
|
ChatgptConversionLimitView chatgptConversionLimitView = new ChatgptConversionLimitView();
|
|
|
ChatgptConversionLimitView.Detail detail = new ChatgptConversionLimitView.Detail();
|
|
|
- detail.setMessage("您目前的套餐已达到GPT-4的使用上限。您现在可以继续使用默认模型,或者重试在");
|
|
|
- detail.setCode("model_cap_exceeded");
|
|
|
- detail.setClears_in(conversationLimitResponse.getNextAvailableTime() / 1000);
|
|
|
+ new Date(System.currentTimeMillis() + conversationLimitResponse.getNextAvailableTime() / 1000);
|
|
|
+ detail.setMessage("您目前的套餐已达到GPT-4的使用上限。您可以继续使用3.5,预计 " + DateUtil.format( new Date(System.currentTimeMillis() + conversationLimitResponse.getNextAvailableTime()), "HH:mm:ss") + " 恢复");
|
|
|
chatgptConversionLimitView.setDetail(detail);
|
|
|
return chatgptConversionLimitView;
|
|
|
} else {
|
|
|
response.setStatus(200);
|
|
|
+ //记录提问时间,车次,标题和模型
|
|
|
+ TASK_EXECUTOR.execute(() -> {
|
|
|
+ chatGptAccountService.saveConversationRecord(userToken, conversationRequest);
|
|
|
+ });
|
|
|
}
|
|
|
//5.获取 conversationRequest 中的model 字段,判断是否为 gpt-4 如果为gpt-4 执行 查看是否达到限制方法
|
|
|
//6.如果达到限制,返回状态码 429 并返回文本 xxx
|
|
|
}
|
|
|
|
|
|
- //记录提问时间,车次,标题和模型
|
|
|
- TASK_EXECUTOR.execute(() -> {
|
|
|
- chatGptAccountService.saveConversationRecord(userToken, conversationRequest);
|
|
|
- });
|
|
|
-
|
|
|
return new ChatgptConversionLimitView();
|
|
|
}
|
|
|
|