From 71e3240af6d8f2f29f1b847d0853881c81e108d0 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Thu, 25 Apr 2024 15:48:48 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96=EF=BC=8C=E7=BB=9F=E4=B8=80=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0ai=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...m.java => AiChatConversationTypeEnum.java} | 6 +- ...yEnum.java => AiChatRoleClassifyEnum.java} | 6 +- ...rceEnum.java => AiChatRoleSourceEnum.java} | 6 +- ...num.java => AiChatRoleVisibilityEnum.java} | 6 +- ...{ChatTypeEnum.java => AiChatTypeEnum.java} | 6 +- ...iModelEnum.java => AiOpenAiModelEnum.java} | 2 +- ...tController.java => AiChatController.java} | 18 ++---- ...java => AiChatConversationController.java} | 22 +++---- ...ller.java => AiChatMessageController.java} | 12 ++-- ...troller.java => AiChatRoleController.java} | 14 ++--- ...rt.java => AiChatConversationConvert.java} | 10 ++-- ...Convert.java => AiChatMessageConvert.java} | 8 +-- ...alConvert.java => AiChatModalConvert.java} | 4 +- ...oleConvert.java => AiChatRoleConvert.java} | 16 ++--- .../module/ai/mapper/AiChatMessageMapper.java | 1 - .../ai/service/AiChatConversationService.java | 58 +++++++++++++++++++ ...Service.java => AiChatMessageService.java} | 8 +-- ...oleService.java => AiChatRoleService.java} | 13 ++--- .../{ChatService.java => AiChatService.java} | 8 +-- .../ai/service/ChatConversationService.java | 58 ------------------- ...ava => AiChatConversationServiceImpl.java} | 42 +++++++------- ...mpl.java => AiChatMessageServiceImpl.java} | 14 ++--- .../service/impl/AiChatModalServiceImpl.java | 8 +-- ...ceImpl.java => AiChatRoleServiceImpl.java} | 40 ++++++------- ...erviceImpl.java => AiChatServiceImpl.java} | 24 ++++---- ...a => AiChatConversationCreateRoleReq.java} | 2 +- ...a => AiChatConversationCreateUserReq.java} | 2 +- ...eq.java => AiChatConversationListReq.java} | 2 +- ...ionRes.java => AiChatConversationRes.java} | 2 +- ...teReq.java => AiChatMessageDeleteReq.java} | 2 +- ...ListRes.java => AiChatMessageListRes.java} | 2 +- ...tMessageReq.java => AiChatMessageReq.java} | 2 +- .../ai/vo/{ChatReq.java => AiChatReq.java} | 2 +- .../yudao/module/ai/vo/AiChatReqVO.java | 4 +- ...tRoleAddReq.java => AiChatRoleAddReq.java} | 2 +- ...oleListReq.java => AiChatRoleListReq.java} | 2 +- ...oleListRes.java => AiChatRoleListRes.java} | 2 +- ...pdateReq.java => AiChatRoleUpdateReq.java} | 2 +- ...ava => AiChatRoleUpdateVisibilityReq.java} | 2 +- 39 files changed, 215 insertions(+), 225 deletions(-) rename yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/{ChatConversationTypeEnum.java => AiChatConversationTypeEnum.java} (75%) rename yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/{ChatRoleClassifyEnum.java => AiChatRoleClassifyEnum.java} (74%) rename yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/{ChatRoleSourceEnum.java => AiChatRoleSourceEnum.java} (75%) rename yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/{ChatRoleVisibilityEnum.java => AiChatRoleVisibilityEnum.java} (73%) rename yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/{ChatTypeEnum.java => AiChatTypeEnum.java} (78%) rename yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/{OpenAiModelEnum.java => AiOpenAiModelEnum.java} (96%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/{ChatController.java => AiChatController.java} (78%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/{ChatConversationController.java => AiChatConversationController.java} (62%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/{ChatMessageController.java => AiChatMessageController.java} (76%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/{ChatRoleController.java => AiChatRoleController.java} (79%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/{ChatConversationConvert.java => AiChatConversationConvert.java} (57%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/{ChatMessageConvert.java => AiChatMessageConvert.java} (61%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/{ChatModalConvert.java => AiChatModalConvert.java} (86%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/{ChatRoleConvert.java => AiChatRoleConvert.java} (53%) create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatConversationService.java rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/{ChatMessageService.java => AiChatMessageService.java} (65%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/{ChatRoleService.java => AiChatRoleService.java} (66%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/{ChatService.java => AiChatService.java} (67%) delete mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatConversationService.java rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/{ChatConversationServiceImpl.java => AiChatConversationServiceImpl.java} (68%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/{ChatMessageServiceImpl.java => AiChatMessageServiceImpl.java} (83%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/{ChatRoleServiceImpl.java => AiChatRoleServiceImpl.java} (67%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/{ChatServiceImpl.java => AiChatServiceImpl.java} (86%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatConversationCreateRoleReq.java => AiChatConversationCreateRoleReq.java} (92%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatConversationCreateUserReq.java => AiChatConversationCreateUserReq.java} (90%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatConversationListReq.java => AiChatConversationListReq.java} (89%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatConversationRes.java => AiChatConversationRes.java} (95%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatMessageDeleteReq.java => AiChatMessageDeleteReq.java} (91%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatMessageListRes.java => AiChatMessageListRes.java} (97%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatMessageReq.java => AiChatMessageReq.java} (91%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatReq.java => AiChatReq.java} (98%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatRoleAddReq.java => AiChatRoleAddReq.java} (96%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatRoleListReq.java => AiChatRoleListReq.java} (87%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatRoleListRes.java => AiChatRoleListRes.java} (97%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatRoleUpdateReq.java => AiChatRoleUpdateReq.java} (96%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/{ChatRoleUpdateVisibilityReq.java => AiChatRoleUpdateVisibilityReq.java} (88%) diff --git a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatConversationTypeEnum.java b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatConversationTypeEnum.java similarity index 75% rename from yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatConversationTypeEnum.java rename to yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatConversationTypeEnum.java index 18891bbe7..a91bed98d 100644 --- a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatConversationTypeEnum.java +++ b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatConversationTypeEnum.java @@ -13,7 +13,7 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public enum ChatConversationTypeEnum { +public enum AiChatConversationTypeEnum { // roleChat、userChat ROLE_CHAT("roleChat", "角色对话"), @@ -25,8 +25,8 @@ public enum ChatConversationTypeEnum { private String name; - public static ChatConversationTypeEnum valueOfType(String type) { - for (ChatConversationTypeEnum itemEnum : ChatConversationTypeEnum.values()) { + public static AiChatConversationTypeEnum valueOfType(String type) { + for (AiChatConversationTypeEnum itemEnum : AiChatConversationTypeEnum.values()) { if (itemEnum.getType().equals(type)) { return itemEnum; } diff --git a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleClassifyEnum.java b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatRoleClassifyEnum.java similarity index 74% rename from yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleClassifyEnum.java rename to yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatRoleClassifyEnum.java index 583bf7483..2221ef737 100644 --- a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleClassifyEnum.java +++ b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatRoleClassifyEnum.java @@ -12,7 +12,7 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public enum ChatRoleClassifyEnum { +public enum AiChatRoleClassifyEnum { WRITING("writing", "写作"), @@ -26,8 +26,8 @@ public enum ChatRoleClassifyEnum { private String name; - public static ChatRoleClassifyEnum valueOfClassify(String classify) { - for (ChatRoleClassifyEnum itemEnum : ChatRoleClassifyEnum.values()) { + public static AiChatRoleClassifyEnum valueOfClassify(String classify) { + for (AiChatRoleClassifyEnum itemEnum : AiChatRoleClassifyEnum.values()) { if (itemEnum.getClassify().equals(classify)) { return itemEnum; } diff --git a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleSourceEnum.java b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatRoleSourceEnum.java similarity index 75% rename from yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleSourceEnum.java rename to yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatRoleSourceEnum.java index 877da17ba..94b004456 100644 --- a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleSourceEnum.java +++ b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatRoleSourceEnum.java @@ -12,7 +12,7 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public enum ChatRoleSourceEnum { +public enum AiChatRoleSourceEnum { SYSTEM("system", "系统"), CUSTOMER("customer", "用户自定义"), @@ -25,8 +25,8 @@ public enum ChatRoleSourceEnum { private String name; - public static ChatRoleSourceEnum valueOfType(String type) { - for (ChatRoleSourceEnum itemEnum : ChatRoleSourceEnum.values()) { + public static AiChatRoleSourceEnum valueOfType(String type) { + for (AiChatRoleSourceEnum itemEnum : AiChatRoleSourceEnum.values()) { if (itemEnum.getType().equals(type)) { return itemEnum; } diff --git a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleVisibilityEnum.java b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatRoleVisibilityEnum.java similarity index 73% rename from yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleVisibilityEnum.java rename to yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatRoleVisibilityEnum.java index c8b09aedb..ec7a19a2c 100644 --- a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleVisibilityEnum.java +++ b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatRoleVisibilityEnum.java @@ -12,7 +12,7 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public enum ChatRoleVisibilityEnum { +public enum AiChatRoleVisibilityEnum { PUBLIC("public", "公开"), PRIVATE("private", "私有的"), @@ -24,8 +24,8 @@ public enum ChatRoleVisibilityEnum { private String name; - public static ChatRoleVisibilityEnum valueOfType(String type) { - for (ChatRoleVisibilityEnum itemEnum : ChatRoleVisibilityEnum.values()) { + public static AiChatRoleVisibilityEnum valueOfType(String type) { + for (AiChatRoleVisibilityEnum itemEnum : AiChatRoleVisibilityEnum.values()) { if (itemEnum.getType().equals(type)) { return itemEnum; } diff --git a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatTypeEnum.java b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatTypeEnum.java similarity index 78% rename from yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatTypeEnum.java rename to yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatTypeEnum.java index cdf7c3ba0..6ee7fabf6 100644 --- a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatTypeEnum.java +++ b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiChatTypeEnum.java @@ -12,7 +12,7 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public enum ChatTypeEnum { +public enum AiChatTypeEnum { ROLE_CHAT("roleChat", "角色模板聊天"), USER_CHAT("userChat", "用户普通聊天"), @@ -23,8 +23,8 @@ public enum ChatTypeEnum { private String name; - public static ChatTypeEnum valueOfType(String type) { - for (ChatTypeEnum itemEnum : ChatTypeEnum.values()) { + public static AiChatTypeEnum valueOfType(String type) { + for (AiChatTypeEnum itemEnum : AiChatTypeEnum.values()) { if (itemEnum.getType().equals(type)) { return itemEnum; } diff --git a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/OpenAiModelEnum.java b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiOpenAiModelEnum.java similarity index 96% rename from yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/OpenAiModelEnum.java rename to yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiOpenAiModelEnum.java index 3daa3f57b..d87c980ba 100644 --- a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/OpenAiModelEnum.java +++ b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiOpenAiModelEnum.java @@ -10,7 +10,7 @@ import lombok.Getter; */ @Getter @AllArgsConstructor -public enum OpenAiModelEnum { +public enum AiOpenAiModelEnum { /** * open ai 3.5模型 diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatController.java similarity index 78% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatController.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatController.java index 9b7f9f3a9..09b83fcad 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatController.java @@ -1,10 +1,8 @@ package cn.iocoder.yudao.module.ai.controller; -import cn.hutool.core.exceptions.ExceptionUtil; -import cn.iocoder.yudao.framework.ai.chat.ChatResponse; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.ai.service.ChatService; -import cn.iocoder.yudao.module.ai.vo.ChatReq; +import cn.iocoder.yudao.module.ai.service.AiChatService; +import cn.iocoder.yudao.module.ai.vo.AiChatReq; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; @@ -17,10 +15,6 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import reactor.core.publisher.Flux; - -import java.io.IOException; -import java.util.function.Consumer; /** * ia 模块 @@ -34,21 +28,21 @@ import java.util.function.Consumer; @RequestMapping("/ai") @Slf4j @AllArgsConstructor -public class ChatController { +public class AiChatController { @Autowired - private final ChatService chatService; + private final AiChatService chatService; @Operation(summary = "聊天-chat", description = "这个一般等待时间比较久,需要全部完成才会返回!") @GetMapping("/chat") - public CommonResult chat(@Validated @ModelAttribute ChatReq req) { + public CommonResult chat(@Validated @ModelAttribute AiChatReq req) { return CommonResult.success(chatService.chat(req)); } // 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) - public SseEmitter chatStream(@Validated @ModelAttribute ChatReq req) { + public SseEmitter chatStream(@Validated @ModelAttribute AiChatReq req) { Utf8SseEmitter sseEmitter = new Utf8SseEmitter(); chatService.chatStream(req, sseEmitter); return sseEmitter; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatConversationController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatConversationController.java similarity index 62% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatConversationController.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatConversationController.java index ffd75cd44..e0f942042 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatConversationController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatConversationController.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.module.ai.controller; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.ai.service.ChatConversationService; -import cn.iocoder.yudao.module.ai.vo.ChatConversationCreateRoleReq; -import cn.iocoder.yudao.module.ai.vo.ChatConversationCreateUserReq; -import cn.iocoder.yudao.module.ai.vo.ChatConversationListReq; -import cn.iocoder.yudao.module.ai.vo.ChatConversationRes; +import cn.iocoder.yudao.module.ai.service.AiChatConversationService; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationCreateRoleReq; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationCreateUserReq; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationListReq; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationRes; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; @@ -27,31 +27,31 @@ import java.util.List; @RequestMapping("/ai/chat/conversation") @Slf4j @AllArgsConstructor -public class ChatConversationController { +public class AiChatConversationController { - private final ChatConversationService chatConversationService; + private final AiChatConversationService chatConversationService; @Operation(summary = "创建 - 对话普通对话") @PostMapping("/createConversation") - public CommonResult createConversation(@RequestBody @Validated ChatConversationCreateUserReq req) { + public CommonResult createConversation(@RequestBody @Validated AiChatConversationCreateUserReq req) { return CommonResult.success(chatConversationService.createConversation(req)); } @Operation(summary = "创建 - 对话角色对话") @PostMapping("/createRoleConversation") - public CommonResult createRoleConversation(@RequestBody @Validated ChatConversationCreateRoleReq req) { + public CommonResult createRoleConversation(@RequestBody @Validated AiChatConversationCreateRoleReq req) { return CommonResult.success(chatConversationService.createRoleConversation(req)); } @Operation(summary = "获取 - 获取对话") @GetMapping("/{id}") - public CommonResult getConversation(@PathVariable("id") Long id) { + public CommonResult getConversation(@PathVariable("id") Long id) { return CommonResult.success(chatConversationService.getConversation(id)); } @Operation(summary = "获取 - 获取对话list") @GetMapping("/list") - public CommonResult> listConversation(@ModelAttribute @Validated ChatConversationListReq req) { + public CommonResult> listConversation(@ModelAttribute @Validated AiChatConversationListReq req) { return CommonResult.success(chatConversationService.listConversation(req)); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatMessageController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatMessageController.java similarity index 76% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatMessageController.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatMessageController.java index f86450848..ecfb6c865 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatMessageController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatMessageController.java @@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.ai.controller; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.ai.service.ChatMessageService; -import cn.iocoder.yudao.module.ai.vo.ChatMessageListRes; -import cn.iocoder.yudao.module.ai.vo.ChatMessageReq; +import cn.iocoder.yudao.module.ai.service.AiChatMessageService; +import cn.iocoder.yudao.module.ai.vo.AiChatMessageListRes; +import cn.iocoder.yudao.module.ai.vo.AiChatMessageReq; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.AllArgsConstructor; @@ -24,13 +24,13 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/ai/chat/message") @Slf4j @AllArgsConstructor -public class ChatMessageController { +public class AiChatMessageController { - private final ChatMessageService chatMessageService; + private final AiChatMessageService chatMessageService; @Operation(summary = "聊天记录", description = "查询个人的聊天记录") @GetMapping("/list") - public PageResult list(@Validated @ModelAttribute ChatMessageReq req) { + public PageResult list(@Validated @ModelAttribute AiChatMessageReq req) { return chatMessageService.list(req); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatRoleController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatRoleController.java similarity index 79% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatRoleController.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatRoleController.java index 947329674..137b8bfa4 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/ChatRoleController.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/AiChatRoleController.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.ai.controller; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.ai.service.ChatRoleService; +import cn.iocoder.yudao.module.ai.service.AiChatRoleService; import cn.iocoder.yudao.module.ai.vo.*; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -22,19 +22,19 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/ai/chat") @Slf4j @AllArgsConstructor -public class ChatRoleController { +public class AiChatRoleController { - private final ChatRoleService chatRoleService; + private final AiChatRoleService chatRoleService; @Operation(summary = "chat角色 - 角色列表") @GetMapping("/role/list") - public PageResult list(@Validated @ModelAttribute ChatRoleListReq req) { + public PageResult list(@Validated @ModelAttribute AiChatRoleListReq req) { return chatRoleService.list(req); } @Operation(summary = "chat角色 - 添加") @PutMapping("/role") - public CommonResult add(@Validated @RequestBody ChatRoleAddReq req) { + public CommonResult add(@Validated @RequestBody AiChatRoleAddReq req) { chatRoleService.add(req); return CommonResult.success(null); } @@ -42,7 +42,7 @@ public class ChatRoleController { @Operation(summary = "chat角色 - 修改") @PostMapping("/role/{id}") public CommonResult update(@PathVariable("id") Long id, - @Validated @RequestBody ChatRoleUpdateReq req) { + @Validated @RequestBody AiChatRoleUpdateReq req) { chatRoleService.update(id, req); return CommonResult.success(null); } @@ -50,7 +50,7 @@ public class ChatRoleController { @Operation(summary = "chat角色 - 修改可见性") @PostMapping("/role/{id}/update-visibility") public CommonResult updateVisibility(@PathVariable("id") Long id, - @Validated @RequestBody ChatRoleUpdateVisibilityReq req) { + @Validated @RequestBody AiChatRoleUpdateVisibilityReq req) { chatRoleService.updateVisibility(id, req); return CommonResult.success(null); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatConversationConvert.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatConversationConvert.java similarity index 57% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatConversationConvert.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatConversationConvert.java index b2f6951e4..d6c93a1a5 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatConversationConvert.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatConversationConvert.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.ai.convert; import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatConversationDO; -import cn.iocoder.yudao.module.ai.vo.ChatConversationRes; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationRes; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -15,9 +15,9 @@ import java.util.List; * @since 1.0 */ @Mapper -public interface ChatConversationConvert { +public interface AiChatConversationConvert { - ChatConversationConvert INSTANCE = Mappers.getMapper(ChatConversationConvert.class); + AiChatConversationConvert INSTANCE = Mappers.getMapper(AiChatConversationConvert.class); /** * 转换 - 多个 ChatConversationRes @@ -25,7 +25,7 @@ public interface ChatConversationConvert { * @param top100Conversation * @return */ - List covnertChatConversationResList(List top100Conversation); + List covnertChatConversationResList(List top100Conversation); /** * 转换 - 单个 ChatConversationRes @@ -33,5 +33,5 @@ public interface ChatConversationConvert { * @param aiChatConversationDO * @return */ - ChatConversationRes covnertChatConversationRes(AiChatConversationDO aiChatConversationDO); + AiChatConversationRes covnertChatConversationRes(AiChatConversationDO aiChatConversationDO); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatMessageConvert.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatMessageConvert.java similarity index 61% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatMessageConvert.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatMessageConvert.java index 9176d01a0..3a920a466 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatMessageConvert.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatMessageConvert.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.ai.convert; import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatMessageDO; -import cn.iocoder.yudao.module.ai.vo.ChatMessageListRes; +import cn.iocoder.yudao.module.ai.vo.AiChatMessageListRes; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -15,9 +15,9 @@ import java.util.List; * @since 1.0 */ @Mapper -public interface ChatMessageConvert { +public interface AiChatMessageConvert { - ChatMessageConvert INSTANCE = Mappers.getMapper(ChatMessageConvert.class); + AiChatMessageConvert INSTANCE = Mappers.getMapper(AiChatMessageConvert.class); /** * 转换 ChatMessageListRes @@ -25,5 +25,5 @@ public interface ChatMessageConvert { * @param list * @return */ - List convert(List list); + List convert(List list); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatModalConvert.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatModalConvert.java similarity index 86% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatModalConvert.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatModalConvert.java index a83d4f0ef..cb3f644c0 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatModalConvert.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatModalConvert.java @@ -16,9 +16,9 @@ import java.util.List; * @since 1.0 */ @Mapper -public interface ChatModalConvert { +public interface AiChatModalConvert { - ChatModalConvert INSTANCE = Mappers.getMapper(ChatModalConvert.class); + AiChatModalConvert INSTANCE = Mappers.getMapper(AiChatModalConvert.class); /** * 转换 - AiChatModalListRes diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatRoleConvert.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatRoleConvert.java similarity index 53% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatRoleConvert.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatRoleConvert.java index d30ea8010..80977c442 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/ChatRoleConvert.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/convert/AiChatRoleConvert.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.module.ai.convert; import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatRoleDO; -import cn.iocoder.yudao.module.ai.vo.ChatRoleAddReq; -import cn.iocoder.yudao.module.ai.vo.ChatRoleListRes; -import cn.iocoder.yudao.module.ai.vo.ChatRoleUpdateReq; +import cn.iocoder.yudao.module.ai.vo.AiChatRoleAddReq; +import cn.iocoder.yudao.module.ai.vo.AiChatRoleUpdateReq; +import cn.iocoder.yudao.module.ai.vo.AiChatRoleListRes; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -17,9 +17,9 @@ import java.util.List; * @since 1.0 */ @Mapper -public interface ChatRoleConvert { +public interface AiChatRoleConvert { - ChatRoleConvert INSTANCE = Mappers.getMapper(ChatRoleConvert.class); + AiChatRoleConvert INSTANCE = Mappers.getMapper(AiChatRoleConvert.class); /** * 转换 - ChatRoleListRes @@ -27,7 +27,7 @@ public interface ChatRoleConvert { * @param roleList * @return */ - List convertChatRoleListRes(List roleList); + List convertChatRoleListRes(List roleList); /** * 转换 - AiChatRoleDO @@ -35,7 +35,7 @@ public interface ChatRoleConvert { * @param req * @return */ - AiChatRoleDO convertAiChatRoleDO(ChatRoleAddReq req); + AiChatRoleDO convertAiChatRoleDO(AiChatRoleAddReq req); /** * 转换 - AiChatRoleDO @@ -43,5 +43,5 @@ public interface ChatRoleConvert { * @param req * @return */ - AiChatRoleDO convertAiChatRoleDO(ChatRoleUpdateReq req); + AiChatRoleDO convertAiChatRoleDO(AiChatRoleUpdateReq req); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatMessageMapper.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatMessageMapper.java index ed1127a0b..cdac20ad6 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatMessageMapper.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/mapper/AiChatMessageMapper.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.ai.mapper; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatMessageDO; -import cn.iocoder.yudao.module.ai.vo.ChatMessageReq; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatConversationService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatConversationService.java new file mode 100644 index 000000000..fbae7c8c4 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatConversationService.java @@ -0,0 +1,58 @@ +package cn.iocoder.yudao.module.ai.service; + +import cn.iocoder.yudao.module.ai.vo.AiChatConversationCreateRoleReq; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationCreateUserReq; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationListReq; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationRes; + +import java.util.List; + +/** + * chat 对话 + * + * @fansili + * @since v1.0 + */ +public interface AiChatConversationService { + + /** + * 对话 - 创建普通对话 + * + * @param req + * @return + */ + AiChatConversationRes createConversation(AiChatConversationCreateUserReq req); + + /** + * 对话 - 创建role对话 + * + * @param req + * @return + */ + AiChatConversationRes createRoleConversation(AiChatConversationCreateRoleReq req); + + + /** + * 获取 - 对话 + * + * @param id + * @return + */ + AiChatConversationRes getConversation(Long id); + + /** + * 获取 - 对话列表 + * + * @param req + * @return + */ + List listConversation(AiChatConversationListReq req); + + /** + * 删除 - 根据id + * + * @param id + */ + void delete(Long id); + +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatMessageService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatMessageService.java similarity index 65% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatMessageService.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatMessageService.java index 625bc1b2e..ef1cfa468 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatMessageService.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatMessageService.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.module.ai.service; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.ai.vo.ChatMessageListRes; -import cn.iocoder.yudao.module.ai.vo.ChatMessageReq; +import cn.iocoder.yudao.module.ai.vo.AiChatMessageListRes; +import cn.iocoder.yudao.module.ai.vo.AiChatMessageReq; /** * chat message @@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.ai.vo.ChatMessageReq; * @time 2024/4/24 17:25 * @since 1.0 */ -public interface ChatMessageService { +public interface AiChatMessageService { /** * message - 列表 @@ -19,7 +19,7 @@ public interface ChatMessageService { * @param req * @return */ - PageResult list(ChatMessageReq req); + PageResult list(AiChatMessageReq req); /** * message - 删除 diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatRoleService.java similarity index 66% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleService.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatRoleService.java index d189455e1..d3bd201e9 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatRoleService.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatRoleService.java @@ -1,18 +1,15 @@ package cn.iocoder.yudao.module.ai.service; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.ai.vo.*; -import java.util.List; - /** * chat 角色 * * @fansili * @since v1.0 */ -public interface ChatRoleService { +public interface AiChatRoleService { /** * 获取聊天角色列表 @@ -20,7 +17,7 @@ public interface ChatRoleService { * @param req * @return */ - PageResult list(ChatRoleListReq req); + PageResult list(AiChatRoleListReq req); /** * chat角色 - 添加 @@ -28,7 +25,7 @@ public interface ChatRoleService { * @param req * @return */ - void add(ChatRoleAddReq req); + void add(AiChatRoleAddReq req); /** * chat角色 - 修改 @@ -36,7 +33,7 @@ public interface ChatRoleService { * @param id * @param req */ - void update(Long id, ChatRoleUpdateReq req); + void update(Long id, AiChatRoleUpdateReq req); /** @@ -45,7 +42,7 @@ public interface ChatRoleService { * @param id * @param req */ - void updateVisibility(Long id, ChatRoleUpdateVisibilityReq req); + void updateVisibility(Long id, AiChatRoleUpdateVisibilityReq req); /** * chat角色 - 删除 diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatService.java similarity index 67% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatService.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatService.java index fd19d822a..b3596e9cf 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatService.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/AiChatService.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.ai.service; import cn.iocoder.yudao.module.ai.controller.Utf8SseEmitter; -import cn.iocoder.yudao.module.ai.vo.ChatReq; +import cn.iocoder.yudao.module.ai.vo.AiChatReq; /** * 聊天 chat @@ -10,7 +10,7 @@ import cn.iocoder.yudao.module.ai.vo.ChatReq; * @time 2024/4/14 15:55 * @since 1.0 */ -public interface ChatService { +public interface AiChatService { /** * chat @@ -18,7 +18,7 @@ public interface ChatService { * @param req * @return */ - String chat(ChatReq req); + String chat(AiChatReq req); /** * chat stream @@ -27,5 +27,5 @@ public interface ChatService { * @param sseEmitter * @return */ - void chatStream(ChatReq req, Utf8SseEmitter sseEmitter); + void chatStream(AiChatReq req, Utf8SseEmitter sseEmitter); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatConversationService.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatConversationService.java deleted file mode 100644 index 428a26e10..000000000 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/ChatConversationService.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.ai.service; - -import cn.iocoder.yudao.module.ai.vo.ChatConversationCreateRoleReq; -import cn.iocoder.yudao.module.ai.vo.ChatConversationCreateUserReq; -import cn.iocoder.yudao.module.ai.vo.ChatConversationListReq; -import cn.iocoder.yudao.module.ai.vo.ChatConversationRes; - -import java.util.List; - -/** - * chat 对话 - * - * @fansili - * @since v1.0 - */ -public interface ChatConversationService { - - /** - * 对话 - 创建普通对话 - * - * @param req - * @return - */ - ChatConversationRes createConversation(ChatConversationCreateUserReq req); - - /** - * 对话 - 创建role对话 - * - * @param req - * @return - */ - ChatConversationRes createRoleConversation(ChatConversationCreateRoleReq req); - - - /** - * 获取 - 对话 - * - * @param id - * @return - */ - ChatConversationRes getConversation(Long id); - - /** - * 获取 - 对话列表 - * - * @param req - * @return - */ - List listConversation(ChatConversationListReq req); - - /** - * 删除 - 根据id - * - * @param id - */ - void delete(Long id); - -} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatConversationServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatConversationServiceImpl.java similarity index 68% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatConversationServiceImpl.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatConversationServiceImpl.java index 7b6f5fa8d..8e6a520c7 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatConversationServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatConversationServiceImpl.java @@ -3,17 +3,17 @@ package cn.iocoder.yudao.module.ai.service.impl; import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.ai.ErrorCodeConstants; -import cn.iocoder.yudao.module.ai.convert.ChatConversationConvert; +import cn.iocoder.yudao.module.ai.convert.AiChatConversationConvert; import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatConversationDO; import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatRoleDO; -import cn.iocoder.yudao.module.ai.enums.ChatConversationTypeEnum; +import cn.iocoder.yudao.module.ai.enums.AiChatConversationTypeEnum; import cn.iocoder.yudao.module.ai.mapper.AiChatConversationMapper; import cn.iocoder.yudao.module.ai.mapper.AiChatRoleMapper; -import cn.iocoder.yudao.module.ai.service.ChatConversationService; -import cn.iocoder.yudao.module.ai.vo.ChatConversationCreateRoleReq; -import cn.iocoder.yudao.module.ai.vo.ChatConversationCreateUserReq; -import cn.iocoder.yudao.module.ai.vo.ChatConversationListReq; -import cn.iocoder.yudao.module.ai.vo.ChatConversationRes; +import cn.iocoder.yudao.module.ai.service.AiChatConversationService; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationCreateRoleReq; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationCreateUserReq; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationListReq; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationRes; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; @@ -30,51 +30,51 @@ import java.util.List; @Service @Slf4j @AllArgsConstructor -public class ChatConversationServiceImpl implements ChatConversationService { +public class AiChatConversationServiceImpl implements AiChatConversationService { private final AiChatRoleMapper aiChatRoleMapper; private final AiChatConversationMapper aiChatConversationMapper; @Override - public ChatConversationRes createConversation(ChatConversationCreateUserReq req) { + public AiChatConversationRes createConversation(AiChatConversationCreateUserReq req) { // 获取用户id Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); // 查询最新的对话 AiChatConversationDO latestConversation = aiChatConversationMapper.selectLatestConversation(loginUserId); // 如果有对话没有被使用过,那就返回这个 if (latestConversation != null && latestConversation.getChatCount() <= 0) { - return ChatConversationConvert.INSTANCE.covnertChatConversationRes(latestConversation); + return AiChatConversationConvert.INSTANCE.covnertChatConversationRes(latestConversation); } // 创建新的 Conversation AiChatConversationDO insertConversation = saveConversation(req.getTitle(), loginUserId, - null, null, ChatConversationTypeEnum.USER_CHAT); + null, null, AiChatConversationTypeEnum.USER_CHAT); // 转换 res - return ChatConversationConvert.INSTANCE.covnertChatConversationRes(insertConversation); + return AiChatConversationConvert.INSTANCE.covnertChatConversationRes(insertConversation); } @Override - public ChatConversationRes createRoleConversation(ChatConversationCreateRoleReq req) { + public AiChatConversationRes createRoleConversation(AiChatConversationCreateRoleReq req) { // 获取用户id Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); // 查询最新的对话 AiChatConversationDO latestConversation = aiChatConversationMapper.selectLatestConversation(loginUserId); // 如果有对话没有被使用过,那就返回这个 if (latestConversation != null && latestConversation.getChatCount() <= 0) { - return ChatConversationConvert.INSTANCE.covnertChatConversationRes(latestConversation); + return AiChatConversationConvert.INSTANCE.covnertChatConversationRes(latestConversation); } AiChatRoleDO aiChatRoleDO = aiChatRoleMapper.selectById(req.getChatRoleId()); // 创建新的 Conversation AiChatConversationDO insertConversation = saveConversation(req.getTitle(), loginUserId, - req.getChatRoleId(), aiChatRoleDO.getRoleName(), ChatConversationTypeEnum.ROLE_CHAT); + req.getChatRoleId(), aiChatRoleDO.getRoleName(), AiChatConversationTypeEnum.ROLE_CHAT); // 转换 res - return ChatConversationConvert.INSTANCE.covnertChatConversationRes(insertConversation); + return AiChatConversationConvert.INSTANCE.covnertChatConversationRes(insertConversation); } private @NotNull AiChatConversationDO saveConversation(String title, Long userId, Long chatRoleId, String chatRoleName, - ChatConversationTypeEnum typeEnum) { + AiChatConversationTypeEnum typeEnum) { AiChatConversationDO insertConversation = new AiChatConversationDO(); insertConversation.setId(null); insertConversation.setUserId(userId); @@ -88,22 +88,22 @@ public class ChatConversationServiceImpl implements ChatConversationService { } @Override - public ChatConversationRes getConversation(Long id) { + public AiChatConversationRes getConversation(Long id) { AiChatConversationDO aiChatConversationDO = aiChatConversationMapper.selectById(id); if (aiChatConversationDO == null) { throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_CHAT_CONTINUE_NOT_EXIST); } - return ChatConversationConvert.INSTANCE.covnertChatConversationRes(aiChatConversationDO); + return AiChatConversationConvert.INSTANCE.covnertChatConversationRes(aiChatConversationDO); } @Override - public List listConversation(ChatConversationListReq req) { + public List listConversation(AiChatConversationListReq req) { // 获取用户id Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); // 查询前100对话 List top100Conversation = aiChatConversationMapper.selectTop100Conversation(loginUserId, req.getSearch()); - return ChatConversationConvert.INSTANCE.covnertChatConversationResList(top100Conversation); + return AiChatConversationConvert.INSTANCE.covnertChatConversationResList(top100Conversation); } @Override diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatMessageServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatMessageServiceImpl.java similarity index 83% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatMessageServiceImpl.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatMessageServiceImpl.java index ab0c05ff4..576fff3f5 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatMessageServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatMessageServiceImpl.java @@ -5,14 +5,14 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.ai.ErrorCodeConstants; -import cn.iocoder.yudao.module.ai.convert.ChatMessageConvert; +import cn.iocoder.yudao.module.ai.convert.AiChatMessageConvert; import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatConversationDO; import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatMessageDO; import cn.iocoder.yudao.module.ai.mapper.AiChatConversationMapper; import cn.iocoder.yudao.module.ai.mapper.AiChatMessageMapper; -import cn.iocoder.yudao.module.ai.service.ChatMessageService; -import cn.iocoder.yudao.module.ai.vo.ChatMessageListRes; -import cn.iocoder.yudao.module.ai.vo.ChatMessageReq; +import cn.iocoder.yudao.module.ai.service.AiChatMessageService; +import cn.iocoder.yudao.module.ai.vo.AiChatMessageListRes; +import cn.iocoder.yudao.module.ai.vo.AiChatMessageReq; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -29,13 +29,13 @@ import java.util.List; @AllArgsConstructor @Service @Slf4j -public class ChatMessageServiceImpl implements ChatMessageService { +public class AiChatMessageServiceImpl implements AiChatMessageService { private final AiChatMessageMapper aiChatMessageMapper; private final AiChatConversationMapper aiChatConversationMapper; @Override - public PageResult list(ChatMessageReq req) { + public PageResult list(AiChatMessageReq req) { // 查询 LambdaQueryWrapperX queryWrapperX = new LambdaQueryWrapperX<>(); queryWrapperX.eq(AiChatMessageDO::getChatConversationId, req.getChatConversationId()); @@ -43,7 +43,7 @@ public class ChatMessageServiceImpl implements ChatMessageService { queryWrapperX.orderByDesc(AiChatMessageDO::getId); PageResult pageResult = aiChatMessageMapper.selectPage(req, queryWrapperX); // 转换 res - List messageListResList = ChatMessageConvert.INSTANCE.convert(pageResult.getList()); + List messageListResList = AiChatMessageConvert.INSTANCE.convert(pageResult.getList()); return new PageResult(messageListResList, pageResult.getTotal()); } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatModalServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatModalServiceImpl.java index af1a223c8..9e4b6e41d 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatModalServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatModalServiceImpl.java @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.ai.ErrorCodeConstants; -import cn.iocoder.yudao.module.ai.convert.ChatModalConvert; +import cn.iocoder.yudao.module.ai.convert.AiChatModalConvert; import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatModalDO; import cn.iocoder.yudao.module.ai.enums.AiChatModalDisableEnum; import cn.iocoder.yudao.module.ai.mapper.AiChatModalMapper; @@ -47,14 +47,14 @@ public class AiChatModalServiceImpl implements AiChatModalService { // 查询 PageResult aiChatModalDOPageResult = aiChatModalMapper.selectPage(req, queryWrapperX); // 转换 res - List resList = ChatModalConvert.INSTANCE.convertAiChatModalListRes(aiChatModalDOPageResult.getList()); + List resList = AiChatModalConvert.INSTANCE.convertAiChatModalListRes(aiChatModalDOPageResult.getList()); return new PageResult<>(resList, aiChatModalDOPageResult.getTotal()); } @Override public void add(AiChatModalAddReq req) { // 转换 do - AiChatModalDO insertChatModalDO = ChatModalConvert.INSTANCE.convertAiChatModalDO(req); + AiChatModalDO insertChatModalDO = AiChatModalConvert.INSTANCE.convertAiChatModalDO(req); // insertChatModalDO.setDisable(AiChatModalDisableEnum.NO.getValue()); // 保存数据库 @@ -66,7 +66,7 @@ public class AiChatModalServiceImpl implements AiChatModalService { // 校验模型是否存在 validateChatModalExists(id); // 转换 updateChatModalDO - AiChatModalDO updateChatModalDO = ChatModalConvert.INSTANCE.convertAiChatModalDO(req); + AiChatModalDO updateChatModalDO = AiChatModalConvert.INSTANCE.convertAiChatModalDO(req); updateChatModalDO.setId(id); // 更新数据库 aiChatModalMapper.updateById(updateChatModalDO); diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatRoleServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatRoleServiceImpl.java similarity index 67% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatRoleServiceImpl.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatRoleServiceImpl.java index af2e8336b..870168e2a 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatRoleServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatRoleServiceImpl.java @@ -6,13 +6,13 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.ai.ErrorCodeConstants; -import cn.iocoder.yudao.module.ai.convert.ChatRoleConvert; +import cn.iocoder.yudao.module.ai.convert.AiChatRoleConvert; import cn.iocoder.yudao.module.ai.dal.dataobject.AiChatRoleDO; -import cn.iocoder.yudao.module.ai.enums.ChatRoleClassifyEnum; -import cn.iocoder.yudao.module.ai.enums.ChatRoleSourceEnum; -import cn.iocoder.yudao.module.ai.enums.ChatRoleVisibilityEnum; +import cn.iocoder.yudao.module.ai.enums.AiChatRoleClassifyEnum; +import cn.iocoder.yudao.module.ai.enums.AiChatRoleSourceEnum; +import cn.iocoder.yudao.module.ai.enums.AiChatRoleVisibilityEnum; import cn.iocoder.yudao.module.ai.mapper.AiChatRoleMapper; -import cn.iocoder.yudao.module.ai.service.ChatRoleService; +import cn.iocoder.yudao.module.ai.service.AiChatRoleService; import cn.iocoder.yudao.module.ai.vo.*; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -29,12 +29,12 @@ import java.util.List; @Service @AllArgsConstructor @Slf4j -public class ChatRoleServiceImpl implements ChatRoleService { +public class AiChatRoleServiceImpl implements AiChatRoleService { private final AiChatRoleMapper aiChatRoleMapper; @Override - public PageResult list(ChatRoleListReq req) { + public PageResult list(AiChatRoleListReq req) { // 查询条件 LambdaQueryWrapperX queryWrapperX = new LambdaQueryWrapperX<>(); // search 查询 @@ -48,18 +48,18 @@ public class ChatRoleServiceImpl implements ChatRoleService { Long total = aiChatRoleDOPageResult.getTotal(); List roleList = aiChatRoleDOPageResult.getList(); // 换货res - List chatRoleListResList = ChatRoleConvert.INSTANCE.convertChatRoleListRes(roleList); + List chatRoleListResList = AiChatRoleConvert.INSTANCE.convertChatRoleListRes(roleList); return new PageResult<>(chatRoleListResList, total); } @Override - public void add(ChatRoleAddReq req) { + public void add(AiChatRoleAddReq req) { // 转换enum,并校验enum - ChatRoleClassifyEnum.valueOfClassify(req.getClassify()); - ChatRoleVisibilityEnum.valueOfType(req.getVisibility()); - ChatRoleSourceEnum.valueOfType(req.getRoleSource()); + AiChatRoleClassifyEnum.valueOfClassify(req.getClassify()); + AiChatRoleVisibilityEnum.valueOfType(req.getVisibility()); + AiChatRoleSourceEnum.valueOfType(req.getRoleSource()); // 转换do - AiChatRoleDO insertAiChatRoleDO = ChatRoleConvert.INSTANCE.convertAiChatRoleDO(req); + AiChatRoleDO insertAiChatRoleDO = AiChatRoleConvert.INSTANCE.convertAiChatRoleDO(req); insertAiChatRoleDO.setUserId(SecurityFrameworkUtils.getLoginUserId()); insertAiChatRoleDO.setUseCount(0); // 保存 @@ -67,24 +67,24 @@ public class ChatRoleServiceImpl implements ChatRoleService { } @Override - public void update(Long id, ChatRoleUpdateReq req) { + public void update(Long id, AiChatRoleUpdateReq req) { // 转换enum,并校验enum - ChatRoleClassifyEnum.valueOfClassify(req.getClassify()); - ChatRoleVisibilityEnum.valueOfType(req.getVisibility()); - ChatRoleSourceEnum.valueOfType(req.getRoleSource()); + AiChatRoleClassifyEnum.valueOfClassify(req.getClassify()); + AiChatRoleVisibilityEnum.valueOfType(req.getVisibility()); + AiChatRoleSourceEnum.valueOfType(req.getRoleSource()); // 检查角色是否存在 validateChatRoleExists(id); // 转换do - AiChatRoleDO updateChatRole = ChatRoleConvert.INSTANCE.convertAiChatRoleDO(req); + AiChatRoleDO updateChatRole = AiChatRoleConvert.INSTANCE.convertAiChatRoleDO(req); updateChatRole.setId(id); aiChatRoleMapper.updateById(updateChatRole); } @Override - public void updateVisibility(Long id, ChatRoleUpdateVisibilityReq req) { + public void updateVisibility(Long id, AiChatRoleUpdateVisibilityReq req) { // 转换enum,并校验enum - ChatRoleVisibilityEnum.valueOfType(req.getVisibility()); + AiChatRoleVisibilityEnum.valueOfType(req.getVisibility()); // 检查角色是否存在 validateChatRoleExists(id); // 更新 diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatServiceImpl.java similarity index 86% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatServiceImpl.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatServiceImpl.java index 57e6b7358..1caad8ada 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/ChatServiceImpl.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatServiceImpl.java @@ -12,10 +12,10 @@ import cn.iocoder.yudao.module.ai.enums.AiClientNameEnum; import cn.iocoder.yudao.module.ai.mapper.AiChatConversationMapper; import cn.iocoder.yudao.module.ai.mapper.AiChatMessageMapper; import cn.iocoder.yudao.module.ai.mapper.AiChatRoleMapper; -import cn.iocoder.yudao.module.ai.service.ChatConversationService; -import cn.iocoder.yudao.module.ai.service.ChatService; -import cn.iocoder.yudao.module.ai.vo.ChatConversationRes; -import cn.iocoder.yudao.module.ai.vo.ChatReq; +import cn.iocoder.yudao.module.ai.service.AiChatConversationService; +import cn.iocoder.yudao.module.ai.service.AiChatService; +import cn.iocoder.yudao.module.ai.vo.AiChatConversationRes; +import cn.iocoder.yudao.module.ai.vo.AiChatReq; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; @@ -36,13 +36,13 @@ import java.util.function.Consumer; @Slf4j @Service @AllArgsConstructor -public class ChatServiceImpl implements ChatService { +public class AiChatServiceImpl implements AiChatService { private final AiClient aiClient; private final AiChatRoleMapper aiChatRoleMapper; private final AiChatMessageMapper aiChatMessageMapper; private final AiChatConversationMapper aiChatConversationMapper; - private final ChatConversationService chatConversationService; + private final AiChatConversationService chatConversationService; /** * chat @@ -51,12 +51,12 @@ public class ChatServiceImpl implements ChatService { * @return */ @Transactional(rollbackFor = Exception.class) - public String chat(ChatReq req) { + public String chat(AiChatReq req) { Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); // 获取 client 类型 AiClientNameEnum clientNameEnum = AiClientNameEnum.valueOfName(req.getModal()); // 获取对话信息 - ChatConversationRes conversationRes = chatConversationService.getConversation(req.getConversationId()); + AiChatConversationRes conversationRes = chatConversationService.getConversation(req.getConversationId()); // 保存 chat message saveChatMessage(req, conversationRes, loginUserId); String content = null; @@ -80,7 +80,7 @@ public class ChatServiceImpl implements ChatService { return content; } - private void saveChatMessage(ChatReq req, ChatConversationRes conversationRes, Long loginUserId) { + private void saveChatMessage(AiChatReq req, AiChatConversationRes conversationRes, Long loginUserId) { Long chatConversationId = conversationRes.getId(); // 增加 chat message 记录 aiChatMessageMapper.insert( @@ -98,7 +98,7 @@ public class ChatServiceImpl implements ChatService { aiChatConversationMapper.updateIncrChatCount(req.getConversationId()); } - public void saveSystemChatMessage(ChatReq req, ChatConversationRes conversationRes, Long loginUserId, String systemPrompts) { + public void saveSystemChatMessage(AiChatReq req, AiChatConversationRes conversationRes, Long loginUserId, String systemPrompts) { Long chatConversationId = conversationRes.getId(); // 增加 chat message 记录 aiChatMessageMapper.insert( @@ -125,12 +125,12 @@ public class ChatServiceImpl implements ChatService { * @return */ @Override - public void chatStream(ChatReq req, Utf8SseEmitter sseEmitter) { + public void chatStream(AiChatReq req, Utf8SseEmitter sseEmitter) { Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); // 获取 client 类型 AiClientNameEnum clientNameEnum = AiClientNameEnum.valueOfName(req.getModal()); // 获取对话信息 - ChatConversationRes conversationRes = chatConversationService.getConversation(req.getConversationId()); + AiChatConversationRes conversationRes = chatConversationService.getConversation(req.getConversationId()); // 创建 chat 需要的 Prompt Prompt prompt = new Prompt(req.getPrompt()); req.setTopK(req.getTopK()); diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationCreateRoleReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationCreateRoleReq.java similarity index 92% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationCreateRoleReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationCreateRoleReq.java index 9af6a44ef..95223ce9f 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationCreateRoleReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationCreateRoleReq.java @@ -14,7 +14,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatConversationCreateRoleReq { +public class AiChatConversationCreateRoleReq { @Schema(description = "chat角色Id") @NotNull(message = "聊天角色id不能为空!") diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationCreateUserReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationCreateUserReq.java similarity index 90% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationCreateUserReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationCreateUserReq.java index 9f967175e..c8276ef80 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationCreateUserReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationCreateUserReq.java @@ -14,7 +14,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatConversationCreateUserReq { +public class AiChatConversationCreateUserReq { @Schema(description = "对话标题") @NotNull(message = "标题不能为空!") diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationListReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationListReq.java similarity index 89% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationListReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationListReq.java index 846c8b2bc..208bf67a2 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationListReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationListReq.java @@ -13,7 +13,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatConversationListReq { +public class AiChatConversationListReq { @Schema(description = "查询根据title") private String search; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationRes.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationRes.java similarity index 95% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationRes.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationRes.java index aa11c0464..ca8254d5f 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatConversationRes.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatConversationRes.java @@ -13,7 +13,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatConversationRes { +public class AiChatConversationRes { @Schema(description = "id") private Long id; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageDeleteReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatMessageDeleteReq.java similarity index 91% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageDeleteReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatMessageDeleteReq.java index 9b2986e81..dafd7d84f 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageDeleteReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatMessageDeleteReq.java @@ -15,7 +15,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatMessageDeleteReq extends PageParam { +public class AiChatMessageDeleteReq extends PageParam { @Schema(description = "id") @NotNull diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageListRes.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatMessageListRes.java similarity index 97% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageListRes.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatMessageListRes.java index 52017c062..ecfbc009c 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageListRes.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatMessageListRes.java @@ -13,7 +13,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatMessageListRes { +public class AiChatMessageListRes { @Schema(description = "编号") private Long id; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatMessageReq.java similarity index 91% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatMessageReq.java index b0f38a321..60b7e91ee 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatMessageReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatMessageReq.java @@ -15,7 +15,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatMessageReq extends PageParam { +public class AiChatMessageReq extends PageParam { @Schema(description = "聊天ID,关联到特定的会话或对话") @NotNull diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatReq.java similarity index 98% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatReq.java index cf41e4cf8..0597f8990 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatReq.java @@ -15,7 +15,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatReq { +public class AiChatReq { @Schema(description = "ai模型(查看 AiClientNameEnum)") @NotNull(message = "模型不能为空!") diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatReqVO.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatReqVO.java index eafbecda5..f4bca2fd6 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatReqVO.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatReqVO.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.ai.vo; -import cn.iocoder.yudao.module.ai.enums.OpenAiModelEnum; +import cn.iocoder.yudao.module.ai.enums.AiOpenAiModelEnum; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import lombok.Data; @@ -16,6 +16,6 @@ public class AiChatReqVO { @Schema(description = "AI模型", requiredMode = Schema.RequiredMode.REQUIRED) @NotNull(message = "AI模型不能为空") - private OpenAiModelEnum aiModel; + private AiOpenAiModelEnum aiModel; } diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleAddReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleAddReq.java similarity index 96% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleAddReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleAddReq.java index 2c83bc59a..63342c61b 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleAddReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleAddReq.java @@ -14,7 +14,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatRoleAddReq extends PageParam { +public class AiChatRoleAddReq extends PageParam { @NotNull @Schema(description = "模型编号,关联到角色使用的特定模型") diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleListReq.java similarity index 87% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleListReq.java index 32a028b94..1dd5e54ce 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleListReq.java @@ -13,7 +13,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatRoleListReq extends PageParam { +public class AiChatRoleListReq extends PageParam { @Schema(description = "查询") private String search; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListRes.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleListRes.java similarity index 97% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListRes.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleListRes.java index 5babda544..8f582cc58 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleListRes.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleListRes.java @@ -12,7 +12,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatRoleListRes { +public class AiChatRoleListRes { @Schema(description = "id") private Long id; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleUpdateReq.java similarity index 96% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleUpdateReq.java index 6ec165ed8..c6197f8d4 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleUpdateReq.java @@ -14,7 +14,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatRoleUpdateReq extends PageParam { +public class AiChatRoleUpdateReq extends PageParam { @NotNull @Schema(description = "模型编号,关联到角色使用的特定模型") diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateVisibilityReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleUpdateVisibilityReq.java similarity index 88% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateVisibilityReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleUpdateVisibilityReq.java index 764972f49..d0d216b24 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/ChatRoleUpdateVisibilityReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/vo/AiChatRoleUpdateVisibilityReq.java @@ -14,7 +14,7 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -public class ChatRoleUpdateVisibilityReq extends PageParam { +public class AiChatRoleUpdateVisibilityReq extends PageParam { @NotNull @Schema(description = "发布状态,0表示仅自己可见,1表示公开,2表示禁用")