【新增】AI:聊天对话的更新模型

This commit is contained in:
YunaiV 2024-05-15 21:20:18 +08:00
parent c5aab1aebd
commit 20657ccaf3
2 changed files with 5 additions and 4 deletions

View File

@ -18,24 +18,21 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
// TODO @芋艿权限标识
@Tag(name = "管理后台 - 聊天消息") @Tag(name = "管理后台 - 聊天消息")
@RestController @RestController
@RequestMapping("/ai/chat/message") @RequestMapping("/ai/chat/message")
@Slf4j @Slf4j
public class AiChatMessageController { public class AiChatMessageController {
@Resource @Resource
private AiChatService chatService; private AiChatService chatService;
@Operation(summary = "发送消息(段式)", description = "一次性返回,响应较慢") @Operation(summary = "发送消息(段式)", description = "一次性返回,响应较慢")
@PostMapping("/send") @PostMapping("/send")
public CommonResult<AiChatMessageRespVO> sendMessage(@Validated @RequestBody AiChatMessageSendReqVO sendReqVO) { public CommonResult<AiChatMessageRespVO> sendMessage(@Validated @RequestBody AiChatMessageSendReqVO sendReqVO) {
// TODO done @fan使用 static import这样就 success 就行了
return success(chatService.chat(sendReqVO)); return success(chatService.chat(sendReqVO));
} }
// TODO @芋艿调用这个方法异常Unable to handle the Spring Security Exception because the response is already committed.可以再试试
// TODO @fan要不要使用 Flux 来返回可以使用 Flux<AiChatMessageRespVO>
@Operation(summary = "发送消息(流式)", description = "流式返回,响应较快") @Operation(summary = "发送消息(流式)", description = "流式返回,响应较快")
@PostMapping(value = "/send-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) @PostMapping(value = "/send-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@PermitAll // 解决 SSE 最终响应的时候会被 Access Denied 拦截的问题 @PermitAll // 解决 SSE 最终响应的时候会被 Access Denied 拦截的问题

View File

@ -32,11 +32,15 @@ public class AiChatConversationRespVO implements VO {
private Long roleId; private Long roleId;
@Schema(description = "模型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "模型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@Trans(type = TransType.SIMPLE, target = AiChatModelDO.class, fields = "name", ref = "modelName")
private Long modelId; private Long modelId;
@Schema(description = "模型标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "ERNIE-Bot-turbo-0922") @Schema(description = "模型标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "ERNIE-Bot-turbo-0922")
private String model; private String model;
@Schema(description = "模型名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
private String modelName;
@Schema(description = "角色设定", example = "一个快乐的程序员") @Schema(description = "角色设定", example = "一个快乐的程序员")
private String systemMessage; private String systemMessage;