From 652a8f96332c5a59169b5e07ca0a5166dae910aa Mon Sep 17 00:00:00 2001 From: cherishsince Date: Sun, 14 Apr 2024 13:38:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=20chat=20role=20=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/OldChatController.java | 77 ------------------- .../ai/controller/admin/package-info.java | 5 ++ .../app/{ => chat}/vo/ChatRoleUpdateReq.java | 2 +- .../vo/ChatRoleUpdateVisibilityReq.java | 2 +- .../ai/controller/{ => app}/package-info.java | 2 +- 5 files changed, 8 insertions(+), 80 deletions(-) delete mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/OldChatController.java create mode 100644 yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/package-info.java rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/{ => chat}/vo/ChatRoleUpdateReq.java (86%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/{ => chat}/vo/ChatRoleUpdateVisibilityReq.java (87%) rename yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/{ => app}/package-info.java (50%) diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/OldChatController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/OldChatController.java deleted file mode 100644 index 49fae6b623..0000000000 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/OldChatController.java +++ /dev/null @@ -1,77 +0,0 @@ -//package cn.iocoder.yudao.module.ai.controller.admin; -// -//import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; -//import cn.iocoder.yudao.framework.common.pojo.CommonResult; -//import cn.iocoder.yudao.module.ai.ErrorCodeConstants; -//import cn.iocoder.yudao.module.ai.controller.admin.vo.AiChatReqVO; -//import cn.iocoder.yudao.module.ai.enums.OpenAiModelEnum; -//import io.swagger.v3.oas.annotations.Operation; -//import io.swagger.v3.oas.annotations.tags.Tag; -//import jakarta.servlet.http.HttpServletResponse; -//import lombok.extern.slf4j.Slf4j; -//import org.springframework.ai.chat.ChatClient; -//import org.springframework.ai.chat.ChatResponse; -//import org.springframework.ai.chat.prompt.Prompt; -//import org.springframework.ai.openai.OpenAiChatClient; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.context.ApplicationContext; -//import org.springframework.validation.annotation.Validated; -//import org.springframework.web.bind.annotation.PostMapping; -//import org.springframework.web.bind.annotation.RequestBody; -//import org.springframework.web.bind.annotation.RequestMapping; -//import org.springframework.web.bind.annotation.RestController; -//import reactor.core.publisher.Flux; -// -//import java.util.function.Consumer; -// -//// TODO done @fansili:有了 swagger 注释,就不用类注释了 -//@Tag(name = "AI模块") -//@RestController -//@RequestMapping("/ai-api") -//@Slf4j -//public class ChatController { -// -// @Autowired -// private ApplicationContext applicationContext; -// -// @PostMapping("/chat") -// @Operation(summary = "对话聊天", description = "简单的ai聊天") -// public CommonResult chat(@RequestBody @Validated AiChatReqVO reqVO) { -// ChatClient chatClient = getChatClient(reqVO.getAiModel()); -// String res; -// try { -// res = chatClient.call(reqVO.getPrompt()); -// } catch (Exception e) { -// res = e.getMessage(); -// } -// return CommonResult.success(res); -// } -// -// @PostMapping("/chatStream") -// @Operation(summary = "对话聊天chatStream", description = "简单的ai聊天") -// public CommonResult chatStream(HttpServletResponse response, @RequestBody @Validated AiChatReqVO reqVO) throws InterruptedException { -// OpenAiChatClient chatClient = applicationContext.getBean(OpenAiChatClient.class); -// Flux chatResponse = chatClient.stream(new Prompt(reqVO.getPrompt())); -// chatResponse.subscribe(new Consumer() { -// @Override -// public void accept(ChatResponse chatResponse) { -// System.err.println(chatResponse.getResults().get(0).getOutput().getContent()); -// } -// }); -// return CommonResult.success(null); -// } -// -// /** -// * 根据 ai模型 获取对于的 模型实现类 -// * -// * @param aiModelEnum -// * @return -// */ -// private ChatClient getChatClient(OpenAiModelEnum aiModelEnum) { -// if (OpenAiModelEnum.OPEN_AI_GPT_3_5 == aiModelEnum) { -// return applicationContext.getBean(OpenAiChatClient.class); -// } -// // AI模型暂不支持 -// throw ServiceExceptionUtil.exception(ErrorCodeConstants.AI_MODULE_NOT_SUPPORTED); -// } -//} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/package-info.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/package-info.java new file mode 100644 index 0000000000..81fe7e4bb4 --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/package-info.java @@ -0,0 +1,5 @@ +/** + * author: fansili + * time: 2024/3/4 13:08 + */ +package cn.iocoder.yudao.module.ai.controller.admin; \ No newline at end of file diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleUpdateReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateReq.java similarity index 86% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleUpdateReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateReq.java index f5a8948814..0874fd6914 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleUpdateReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateReq.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.ai.controller.app.vo; +package cn.iocoder.yudao.module.ai.controller.app.chat.vo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleUpdateVisibilityReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateVisibilityReq.java similarity index 87% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleUpdateVisibilityReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateVisibilityReq.java index bd1836b5eb..fc76b5d4ca 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleUpdateVisibilityReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleUpdateVisibilityReq.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.ai.controller.app.vo; +package cn.iocoder.yudao.module.ai.controller.app.chat.vo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/package-info.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/package-info.java similarity index 50% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/package-info.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/package-info.java index f154471727..a7675c99bd 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/package-info.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/package-info.java @@ -2,4 +2,4 @@ * author: fansili * time: 2024/3/4 13:08 */ -package cn.iocoder.yudao.module.ai.controller; \ No newline at end of file +package cn.iocoder.yudao.module.ai.controller.app; \ No newline at end of file