浏览代码

适配最新的core-ai模块,增加测试接口代码

luoshi 1 年之前
父节点
当前提交
3e0ef25d1f

+ 4 - 0
api-demo/pom.xml

@@ -53,6 +53,10 @@
             <groupId>com.qmth.boot</groupId>
             <artifactId>core-sms</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.qmth.boot</groupId>
+            <artifactId>core-ai</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>

+ 49 - 0
api-demo/src/main/java/com/qmth/demo/api/controller/AiController.java

@@ -0,0 +1,49 @@
+package com.qmth.demo.api.controller;
+
+import com.qmth.boot.api.annotation.Aac;
+import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.boot.core.ai.model.llm.AutoScoreRequest;
+import com.qmth.boot.core.ai.model.llm.LlmAppType;
+import com.qmth.boot.core.ai.service.AiService;
+import com.qmth.boot.core.retrofit.utils.SignatureInfo;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/ai")
+@Aac(auth = false)
+public class AiController {
+
+    @Resource
+    private AiService aiService;
+
+    @RequestMapping("/balance")
+    public Object getBalance(@RequestParam LlmAppType appType, @RequestParam String accessKey) {
+        return aiService.getLlmBalance(appType, SignatureInfo.secret(accessKey, ""));
+    }
+
+    @RequestMapping("/auto_generate_question")
+    public Object autoGenerateQuestion(@RequestParam String accessKey) {
+        Map<String, Object> param = new HashMap<>();
+        return aiService.autoGenerateQuestion(param, SignatureInfo.secret(accessKey, ""));
+    }
+
+    @RequestMapping("/auto_score")
+    public Object autoScore(@RequestParam String accessKey, AutoScoreRequest request) {
+        return aiService.autoScore(request, SignatureInfo.secret(accessKey, ""));
+    }
+
+    @RequestMapping("/auto_score_image")
+    public Object autoScore(@RequestParam String accessKey, AutoScoreRequest request, @RequestParam MultipartFile image)
+            throws IOException {
+        return aiService.autoScore(request, image.getBytes(), SignatureInfo.secret(accessKey, ""));
+    }
+
+}

+ 4 - 0
api-demo/src/main/resources/application.properties

@@ -43,3 +43,7 @@ com.qmth.solar.accessSecret=nujVkeIsWKIfRTvL3g4JzomKZ7qbhH1k
 #com.qmth.sms.server=http://localhost:8090
 
 #com.qmth.lock.log-level=debug
+
+##ai
+com.qmth.llm.server=http://localhost:8090
+com.qmth.ocr.server=http://localhost:8090

+ 5 - 0
pom.xml

@@ -66,6 +66,11 @@
                 <artifactId>core-sms</artifactId>
                 <version>${qmth.boot.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.qmth.boot</groupId>
+                <artifactId>core-ai</artifactId>
+                <version>${qmth.boot.version}</version>
+            </dependency>
             <dependency>
                 <groupId>com.qmth.boot</groupId>
                 <artifactId>data-redis</artifactId>