|
@@ -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, ""));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|