| | |
| | | package com.zy.ai.service; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.zy.ai.entity.LlmRouteConfig; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | public void markSuccess(Long routeId) { |
| | | if (routeId == null) return; |
| | | try { |
| | | LlmRouteConfig db = llmRouteConfigService.selectById(routeId); |
| | | LlmRouteConfig db = llmRouteConfigService.getById(routeId); |
| | | if (db == null) return; |
| | | db.setSuccessCount(nvl(db.getSuccessCount()) + 1); |
| | | db.setConsecutiveFailCount(0); |
| | |
| | | public void markFailure(Long routeId, String errorText, boolean enterCooldown, Integer cooldownSeconds) { |
| | | if (routeId == null) return; |
| | | try { |
| | | LlmRouteConfig db = llmRouteConfigService.selectById(routeId); |
| | | LlmRouteConfig db = llmRouteConfigService.getById(routeId); |
| | | if (db == null) return; |
| | | Date now = new Date(); |
| | | db.setFailCount(nvl(db.getFailCount()) + 1); |
| | |
| | | if (now < cacheExpireAt && allRouteCache != null) { |
| | | return allRouteCache; |
| | | } |
| | | EntityWrapper<LlmRouteConfig> wrapper = new EntityWrapper<>(); |
| | | wrapper.orderBy("priority", true).orderBy("id", true); |
| | | List<LlmRouteConfig> list = llmRouteConfigService.selectList(wrapper); |
| | | QueryWrapper<LlmRouteConfig> wrapper = new QueryWrapper<>(); |
| | | wrapper.orderBy(true, true, "priority").orderBy(true, true, "id"); |
| | | List<LlmRouteConfig> list = llmRouteConfigService.list(wrapper); |
| | | if (list == null) { |
| | | allRouteCache = Collections.emptyList(); |
| | | } else { |