Commit 009914ed73f125a21f6e07793a53b53595b81b9d
1 parent
a3530555
增加 swagger 注释
Showing
1 changed file
with
3 additions
and
2 deletions
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatController.java
| @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.ai.chat.ChatResponse; | @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.ai.chat.ChatResponse; | ||
| 5 | import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt; | 5 | import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt; |
| 6 | import cn.iocoder.yudao.framework.ai.config.AiClient; | 6 | import cn.iocoder.yudao.framework.ai.config.AiClient; |
| 7 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 7 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 8 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 8 | import io.swagger.v3.oas.annotations.tags.Tag; | 9 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 9 | import lombok.AllArgsConstructor; | 10 | import lombok.AllArgsConstructor; |
| 10 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| @@ -32,11 +33,10 @@ import java.util.function.Consumer; | @@ -32,11 +33,10 @@ import java.util.function.Consumer; | ||
| 32 | @AllArgsConstructor | 33 | @AllArgsConstructor |
| 33 | public class ChatController { | 34 | public class ChatController { |
| 34 | 35 | ||
| 35 | - | ||
| 36 | - | ||
| 37 | @Autowired | 36 | @Autowired |
| 38 | private AiClient aiClient; | 37 | private AiClient aiClient; |
| 39 | 38 | ||
| 39 | + @Operation(summary = "聊天-chat", description = "这个一般等待时间比较久,需要全部完成才会返回!") | ||
| 40 | @GetMapping("/chat") | 40 | @GetMapping("/chat") |
| 41 | public CommonResult<String> chat(@RequestParam("prompt") String prompt) { | 41 | public CommonResult<String> chat(@RequestParam("prompt") String prompt) { |
| 42 | ChatResponse callRes = aiClient.call(new Prompt(prompt), "qianWen"); | 42 | ChatResponse callRes = aiClient.call(new Prompt(prompt), "qianWen"); |
| @@ -44,6 +44,7 @@ public class ChatController { | @@ -44,6 +44,7 @@ public class ChatController { | ||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | // TODO @芋艿:调用这个方法异常,Unable to handle the Spring Security Exception because the response is already committed. | 46 | // TODO @芋艿:调用这个方法异常,Unable to handle the Spring Security Exception because the response is already committed. |
| 47 | + @Operation(summary = "聊天-stream", description = "这里跟通义千问一样采用的是 Server-Sent Events (SSE) 通讯模式") | ||
| 47 | @GetMapping(value = "/chatStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) | 48 | @GetMapping(value = "/chatStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) |
| 48 | public SseEmitter chatStream(@RequestParam("prompt") String prompt) { | 49 | public SseEmitter chatStream(@RequestParam("prompt") String prompt) { |
| 49 | Utf8SseEmitter sseEmitter = new Utf8SseEmitter(); | 50 | Utf8SseEmitter sseEmitter = new Utf8SseEmitter(); |