Przeglądaj źródła

fix 次数问题

chenbiao 2 lat temu
rodzic
commit
b45cb688ce

+ 9 - 8
netflix-service/src/main/java/com/cyksj/service/chatgpt/impl/ChatGptAccountServiceImpl.java

@@ -453,13 +453,14 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
         chatgptUserConversationRecord.setModel(conversationRequest.getModel());
         chatgptUserConversationRecordMapper.insert(chatgptUserConversationRecord);
 
-        String key = RedisService.key.CHATGPT_CONVERSATION_LIMIT.getName() + ":" + userToken;
-        long currentTimeMillis = System.currentTimeMillis();
-
-        // 如果未超过限制,记录当前请求的时间戳
-        redisService.zAdd(key, currentTimeMillis, currentTimeMillis);
-        // 设置ZSet的过期时间,窗口大小加上一段冗余时间
-        redisService.expire(key, (chatgptUser.getLimitTime() * 60 * 60) + 20);
+        if(!"text-davinci-002-render-sha".equals(conversationRequest.getModel())){
+            String key = RedisService.key.CHATGPT_CONVERSATION_LIMIT.getName() + ":" + userToken;
+            long currentTimeMillis = System.currentTimeMillis();
+            // 如果未超过限制,记录当前请求的时间戳
+            redisService.zAdd(key, currentTimeMillis, currentTimeMillis);
+            // 设置ZSet的过期时间,窗口大小加上一段冗余时间
+            redisService.expire(key, (chatgptUser.getLimitTime() * 60 * 60) + 20);
+        }
 
         if (StringUtils.isNotBlank(chatgptSession.getCarId())) {
             redisService.del();
@@ -801,7 +802,7 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
                     .expireTime(chatgptUser.getExpireTime())
                     .limitNum(chatgptUser.getLimitNum())
                     .limitTime(chatgptUser.getLimitTime())
-                    .use(getConversationCount(chatgptUser.getUserToken(), chatgptUser.getLimitTime()))
+                    .use(Math.min(chatgptUser.getLimitNum(),getConversationCount(chatgptUser.getUserToken(), chatgptUser.getLimitTime())))
                     .build();
         } else {
             throw BusinessRuntimeException.getInstance("您还未购买该车票");

+ 0 - 1
netflix-web/src/main/java/com/cyksj/web/controller/mirror/MirrorController.java

@@ -34,7 +34,6 @@ import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDateTime;