Эх сурвалжийг харах

临时去掉PromptTemplate服务层缓存;临时增加LlmClientService手动更新入口

luoshi 1 жил өмнө
parent
commit
f8d51be340

+ 34 - 0
src/main/java/com/qmth/ops/api/controller/admin/LlmInfoController.java

@@ -4,9 +4,15 @@ import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.core.ai.model.llm.LlmAppType;
 import com.qmth.ops.api.constants.OpsApiConstants;
 import com.qmth.ops.api.vo.CodeNameVO;
+import com.qmth.ops.biz.service.LlmClientService;
+import com.qmth.ops.biz.service.LlmModelService;
+import com.qmth.ops.biz.service.LlmSupplierService;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -16,6 +22,15 @@ public class LlmInfoController {
 
     private List<CodeNameVO> appTypeList;
 
+    @Resource
+    private LlmSupplierService llmSupplierService;
+
+    @Resource
+    private LlmModelService llmModelService;
+
+    @Resource
+    private LlmClientService llmClientService;
+
     @RequestMapping("/app_types")
     @Aac(auth = false)
     public Object list() {
@@ -27,4 +42,23 @@ public class LlmInfoController {
         return appTypeList;
     }
 
+    @RequestMapping("/client_refresh")
+    @Aac(auth = false)
+    public Object refreshClient(@RequestParam(required = false) Long supplierId,
+            @RequestParam(required = false) Long modelId) {
+        if (supplierId != null) {
+            llmClientService.updateBySupplier(llmSupplierService.getById(supplierId));
+            return new HashMap<String, Long>() {{
+                put("supplierId", supplierId);
+            }};
+        } else if (modelId != null) {
+            llmClientService.updateByModel(llmModelService.getById(modelId));
+            return new HashMap<String, Long>() {{
+                put("modelId", modelId);
+            }};
+        } else {
+            return false;
+        }
+    }
+
 }

+ 3 - 3
src/main/java/com/qmth/ops/biz/service/LlmPromptTemplateService.java

@@ -21,7 +21,7 @@ public class LlmPromptTemplateService {
     @Resource
     private LlmPromptTemplateDao llmPromptTemplateDao;
 
-    @Cacheable(value = CACHE_NAME, key = "#id")
+    //@Cacheable(value = CACHE_NAME, key = "#id")
     public LlmPromptTemplate findById(Long id) {
         return llmPromptTemplateDao.selectById(id);
     }
@@ -33,13 +33,13 @@ public class LlmPromptTemplateService {
     }
 
     @Transactional
-    @CachePut(value = CACHE_NAME, key = "#template.id", unless = "#template==null")
+    //@CachePut(value = CACHE_NAME, key = "#template.id", unless = "#template==null")
     public void insert(LlmPromptTemplate template) {
         llmPromptTemplateDao.insert(template);
     }
 
     @Transactional
-    @CachePut(value = CACHE_NAME, key = "#template.id", unless = "#template==null")
+    //@CachePut(value = CACHE_NAME, key = "#template.id", unless = "#template==null")
     public void update(LlmPromptTemplate template) {
         llmPromptTemplateDao.update(template,
                 new LambdaUpdateWrapper<LlmPromptTemplate>().set(LlmPromptTemplate::getSystem, template.getSystem())