增加 swagger 注释

This commit is contained in:
cherishsince 2024-04-14 15:55:08 +08:00
parent a3530555ca
commit 009914ed73

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.ai.chat.ChatResponse;
import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt; import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt;
import cn.iocoder.yudao.framework.ai.config.AiClient; import cn.iocoder.yudao.framework.ai.config.AiClient;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -32,11 +33,10 @@ import java.util.function.Consumer;
@AllArgsConstructor @AllArgsConstructor
public class ChatController { public class ChatController {
@Autowired @Autowired
private AiClient aiClient; private AiClient aiClient;
@Operation(summary = "聊天-chat", description = "这个一般等待时间比较久,需要全部完成才会返回!")
@GetMapping("/chat") @GetMapping("/chat")
public CommonResult<String> chat(@RequestParam("prompt") String prompt) { public CommonResult<String> chat(@RequestParam("prompt") String prompt) {
ChatResponse callRes = aiClient.call(new Prompt(prompt), "qianWen"); ChatResponse callRes = aiClient.call(new Prompt(prompt), "qianWen");
@ -44,6 +44,7 @@ public class ChatController {
} }
// TODO @芋艿调用这个方法异常Unable to handle the Spring Security Exception because the response is already committed. // TODO @芋艿调用这个方法异常Unable to handle the Spring Security Exception because the response is already committed.
@Operation(summary = "聊天-stream", description = "这里跟通义千问一样采用的是 Server-Sent Events (SSE) 通讯模式")
@GetMapping(value = "/chatStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) @GetMapping(value = "/chatStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public SseEmitter chatStream(@RequestParam("prompt") String prompt) { public SseEmitter chatStream(@RequestParam("prompt") String prompt) {
Utf8SseEmitter sseEmitter = new Utf8SseEmitter(); Utf8SseEmitter sseEmitter = new Utf8SseEmitter();