From b7126f7bd88d3c4a19be9b3c3a7bb36b3e22349c Mon Sep 17 00:00:00 2001 From: winter <2436197699@qq.com> Date: Wed, 24 Apr 2024 15:56:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/frontend/AiController.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/cn/teammodel/controller/frontend/AiController.java b/src/main/java/cn/teammodel/controller/frontend/AiController.java index 848ff97..2a7d2bd 100644 --- a/src/main/java/cn/teammodel/controller/frontend/AiController.java +++ b/src/main/java/cn/teammodel/controller/frontend/AiController.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.concurrent.CompletableFuture; @RestController -@RequestMapping("/ai/api") +@RequestMapping("/ai") @Api(tags = "AI 能力") public class AiController { @Resource @@ -33,12 +33,17 @@ public class AiController { @Resource private ChatAppService chatAppService; - @PostMapping("chat/completion") + @PostMapping("api/chat/completion") @ApiOperation("与 spark 的流式对话") - public SseEmitter chatCompletion(@RequestBody @Valid ChatCompletionReqDto chatCompletionReqDto) { + public SseEmitter chatCompletionToApi(@RequestBody @Valid ChatCompletionReqDto chatCompletionReqDto) { String userId = ((TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal()).getClaims().getSubject(); return chatMessageService.chatCompletion(chatCompletionReqDto, userId); } + @PostMapping("chat/completion") + @ApiOperation("与 spark 的流式对话") + public SseEmitter chatCompletion(@RequestBody @Valid ChatCompletionReqDto chatCompletionReqDto) { + return chatMessageService.chatCompletion(chatCompletionReqDto, null); + } // @PostMapping("chat/test/completion") @ApiOperation("与 spark 的流式对话") @@ -74,7 +79,7 @@ public class AiController { return sseEmitter; } - @GetMapping("session/my") + @GetMapping("api/session/my") @ApiOperation("查询我的聊天会话") public R> listMySession() { String userId = ((TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal()).getClaims().getSubject(); @@ -82,14 +87,14 @@ public class AiController { return R.success(sessions); } - @GetMapping("chat/history/{sessionId}") + @GetMapping("api/chat/history/{sessionId}") @ApiOperation("查询我的聊天记录") public R> getHistory(@PathVariable String sessionId) { String userId = ((TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal()).getClaims().getSubject(); List history = chatSessionService.listHistory(sessionId, userId); return R.success(history); } - @PostMapping("session/create") + @PostMapping("api/session/create") @ApiOperation("创建聊天会话") public R createSession() { String userId = ((TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal()).getClaims().getSubject(); @@ -99,14 +104,14 @@ public class AiController { return R.success(sessionId); } - @PostMapping("session/remove") + @PostMapping("api/session/remove") @ApiOperation("删除聊天会话") public R removeSession(@RequestBody @Valid IdRequest idRequest) { String userId = ((TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal()).getClaims().getSubject(); chatSessionService.deleteSession(idRequest.getId(), userId); return R.success("删除会话成功"); } - @PostMapping("session/update") + @PostMapping("api/session/update") @ApiOperation("更新聊天会话") public R updateSession(@RequestBody @Valid UpdateSessionDto updateSessionDto) { String userId = ((TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal()).getClaims().getSubject();