|
|
@@ -7,10 +7,11 @@ import api.service.ai.AssistantsService;
|
|
7
|
7
|
import api.service.ai.IZhiPuService;
|
|
8
|
8
|
import api.service.ai.QiFanService;
|
|
9
|
9
|
import api.service.ai.XingHuoService;
|
|
10
|
|
-import api.util.annotation.Log;
|
|
11
|
|
-import api.util.enums.BusinessType;
|
|
|
10
|
+import api.util.helper.HttpHelper;
|
|
|
11
|
+import api.util.helper.StringHelper;
|
|
12
|
12
|
import com.alibaba.dashscope.exception.InputRequiredException;
|
|
13
|
13
|
import com.alibaba.dashscope.exception.NoApiKeyException;
|
|
|
14
|
+import com.alibaba.fastjson2.JSON;
|
|
14
|
15
|
import io.swagger.annotations.Api;
|
|
15
|
16
|
import io.swagger.annotations.ApiOperation;
|
|
16
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -23,7 +24,9 @@ import javax.servlet.http.HttpServletRequest;
|
|
23
|
24
|
import javax.servlet.http.HttpServletResponse;
|
|
24
|
25
|
import java.io.IOException;
|
|
25
|
26
|
|
|
|
27
|
+import java.util.HashMap;
|
|
26
|
28
|
import java.util.List;
|
|
|
29
|
+import java.util.Map;
|
|
27
|
30
|
import java.util.Objects;
|
|
28
|
31
|
|
|
29
|
32
|
|
|
|
@@ -40,34 +43,27 @@ public class AIController extends BaseController {
|
|
40
|
43
|
private QiFanService qiFanService;
|
|
41
|
44
|
@Autowired
|
|
42
|
45
|
private XingHuoService xingHuoService;
|
|
|
46
|
+
|
|
43
|
47
|
@ApiOperation("智谱问答同步调用")
|
|
44
|
|
- @Log(title = "智谱问答同步调用",businessType = BusinessType.QUERY)
|
|
45
|
48
|
@GetMapping("/getInvoke")
|
|
46
|
|
- public AjaxResult getInvoke (String question) {
|
|
|
49
|
+ public AjaxResult getInvoke(String question) {
|
|
47
|
50
|
String result = zhiPuService.Invoke(question);
|
|
48
|
51
|
return Success(result);
|
|
49
|
52
|
}
|
|
|
53
|
+
|
|
50
|
54
|
@ApiOperation("sse调用")
|
|
51
|
|
- @Log(title = "sse调用",businessType = BusinessType.QUERY)
|
|
52
|
|
- @PostMapping(value = "/getSseInvoke" ,produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
|
53
|
|
- public SseEmitter getSseInvoke(@RequestBody List<AIInput> Input,String type,
|
|
54
|
|
- HttpServletRequest request, HttpServletResponse response)
|
|
|
55
|
+ @PostMapping(value = "/getSseInvoke", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
|
|
56
|
+ public SseEmitter getSseInvoke(@RequestBody List<AIInput> Input, String type,
|
|
|
57
|
+ HttpServletRequest request, HttpServletResponse response)
|
|
55
|
58
|
throws ServletException, IOException, NoApiKeyException, InputRequiredException, InterruptedException {
|
|
56
|
|
- if (Objects.equals(type, "ZhiPu"))
|
|
57
|
|
- {
|
|
58
|
|
- return zhiPuService.sseInvoke(Input,request,response);
|
|
59
|
|
- }
|
|
60
|
|
- else if (Objects.equals(type, "TongYi"))
|
|
61
|
|
- {
|
|
62
|
|
- return assistantsService.streamCallWithMessage(Input,request,response);
|
|
63
|
|
- }
|
|
64
|
|
- else if (Objects.equals(type, "QianFan"))
|
|
65
|
|
- {
|
|
66
|
|
- return qiFanService.sseInvoke(Input,request,response);
|
|
67
|
|
- }
|
|
68
|
|
- else if (Objects.equals(type, "XingHuo"))
|
|
69
|
|
- {
|
|
70
|
|
- return xingHuoService.sseInvoke(Input,response);
|
|
|
59
|
+ if (Objects.equals(type, "ZhiPu")) {
|
|
|
60
|
+ return zhiPuService.sseInvoke(Input, request, response);
|
|
|
61
|
+ } else if (Objects.equals(type, "TongYi")) {
|
|
|
62
|
+ return assistantsService.streamCallWithMessage(Input, request, response);
|
|
|
63
|
+ } else if (Objects.equals(type, "QianFan")) {
|
|
|
64
|
+ return qiFanService.sseInvoke(Input, request, response);
|
|
|
65
|
+ } else if (Objects.equals(type, "XingHuo")) {
|
|
|
66
|
+ return xingHuoService.sseInvoke(Input, response);
|
|
71
|
67
|
}
|
|
72
|
68
|
return null;
|
|
73
|
69
|
}
|