diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/ChatController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/ChatController.java deleted file mode 100644 index 8fbc6d9e6..000000000 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/ChatController.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.ai.controller.admin; - -import cn.iocoder.yudao.framework.ai.chatqianwen.QianWenChatClient; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author fansili - * @since 1.0 - * @time 2024/4/13 17:44 - */ -@Tag(name = "AI模块") -@RestController -@RequestMapping("/ai-api") -@Slf4j -@AllArgsConstructor -public class ChatController { - -// -// @Autowired -// private QianWenChatClient qianWenChatClient; -// -// @GetMapping("/chat") -// public String chat(@RequestParam("prompt") String prompt) { -// return qianWenChatClient.call(prompt); -// } - -} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/ChatController.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/ChatController.java new file mode 100644 index 000000000..90710a3dd --- /dev/null +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/chat/ChatController.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.ai.controller.admin.chat; + +import cn.iocoder.yudao.framework.ai.chat.ChatResponse; +import cn.iocoder.yudao.framework.ai.chat.prompt.Prompt; +import cn.iocoder.yudao.framework.ai.config.AiClient; +import cn.iocoder.yudao.framework.ai.config.YudaoAiClient; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @author fansili + * @since 1.0 + * @time 2024/4/13 17:44 + */ +@Tag(name = "AI模块") +@RestController +@RequestMapping("/admin-api/ai") +@Slf4j +@AllArgsConstructor +public class ChatController { + + private final AiClient aiClient; + + @PostMapping("/chat") + public CommonResult chat(@RequestParam("prompt") String prompt) { + ChatResponse callRes = aiClient.call(new Prompt(prompt), "qianWen"); + return CommonResult.success(callRes.getResult().getOutput().getContent()); + } + +} diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleAddReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleAddReq.java similarity index 86% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleAddReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleAddReq.java index b3957fafd..b1c08e286 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleAddReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleAddReq.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/ChatRoleListReq.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListReq.java similarity index 86% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleListReq.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListReq.java index 355f00cf6..18f3d46c0 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleListReq.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListReq.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/ChatRoleListRes.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListRes.java similarity index 75% rename from yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleListRes.java rename to yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListRes.java index d788e7876..6480296f2 100644 --- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/vo/ChatRoleListRes.java +++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/app/chat/vo/ChatRoleListRes.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 lombok.Data; import lombok.experimental.Accessors;