From 7f17e14c09f7cf4e7c8eef6cd32f7d79912ef4ea Mon Sep 17 00:00:00 2001 From: lhpqaq <657407891@qq.com> Date: Tue, 12 Nov 2024 18:33:46 +0800 Subject: [PATCH] add detail api for llm --- .../server/controller/ChatbotController.java | 8 +++++++- .../server/controller/LLMConfigController.java | 10 ++++++++-- .../manager/server/service/ChatbotService.java | 2 ++ .../manager/server/service/LLMConfigService.java | 2 ++ .../server/service/impl/ChatbotServiceImpl.java | 13 +++++++++++++ .../server/service/impl/LLMConfigServiceImpl.java | 10 ++++++++++ 6 files changed, 42 insertions(+), 3 deletions(-) diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/ChatbotController.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/ChatbotController.java index 993563e0..667439c9 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/ChatbotController.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/ChatbotController.java @@ -73,7 +73,13 @@ public ResponseEntity deleteChatThread(@PathVariable Long threadId) { return ResponseEntity.success(chatbotService.deleteChatThread(threadId)); } - @Operation(summary = "get threads", description = "Get all threads of a auth platform") + @Operation(summary = "get thread", description = "Get a chat threads") + @GetMapping("/threads/{threadId}") + public ResponseEntity getChatThread(@PathVariable Long threadId) { + return ResponseEntity.success(chatbotService.getChatThread(threadId)); + } + + @Operation(summary = "list threads", description = "List all threads of a auth platform") @GetMapping("/threads") public ResponseEntity> getAllChatThreads() { return ResponseEntity.success(chatbotService.getAllChatThreads()); diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/LLMConfigController.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/LLMConfigController.java index b6e41e24..5effdf22 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/LLMConfigController.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/LLMConfigController.java @@ -50,7 +50,7 @@ public class LLMConfigController { @Resource private LLMConfigService llmConfigService; - @Operation(summary = "get platforms", description = "Get all platforms") + @Operation(summary = "list platforms", description = "List all platforms") @GetMapping("/platforms") public ResponseEntity> platforms() { return ResponseEntity.success(llmConfigService.platforms()); @@ -62,7 +62,7 @@ public ResponseEntity> platformsAuthCredential(@P return ResponseEntity.success(llmConfigService.platformsAuthCredentials(platformId)); } - @Operation(summary = "get auth platforms", description = "Get authorized platforms") + @Operation(summary = "list auth platforms", description = "List authorized platforms") @GetMapping("/auth-platforms") public ResponseEntity> authorizedPlatforms() { return ResponseEntity.success(llmConfigService.authorizedPlatforms()); @@ -91,6 +91,12 @@ public ResponseEntity updateAuthorizedPlatform( return ResponseEntity.success(llmConfigService.updateAuthorizedPlatform(authPlatformDTO)); } + @Operation(summary = "get auth platform", description = "Get authorized platforms") + @GetMapping("/auth-platforms/{authId}") + public ResponseEntity getAuthorizedPlatform(@PathVariable Long authId) { + return ResponseEntity.success(llmConfigService.getAuthorizedPlatform(authId)); + } + @Operation(summary = "delete auth platform", description = "Delete authorized platforms") @DeleteMapping("/auth-platforms/{authId}") public ResponseEntity deleteAuthorizedPlatform(@PathVariable Long authId) { diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/ChatbotService.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/ChatbotService.java index b3c2d613..95fa0643 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/ChatbotService.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/ChatbotService.java @@ -39,4 +39,6 @@ public interface ChatbotService { List history(Long threadId); ChatThreadVO updateChatThread(ChatThreadDTO chatThreadDTO); + + ChatThreadVO getChatThread(Long threadId); } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/LLMConfigService.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/LLMConfigService.java index 96ca25ce..c5400002 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/LLMConfigService.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/LLMConfigService.java @@ -44,4 +44,6 @@ public interface LLMConfigService { boolean activateAuthorizedPlatform(Long authId); boolean deactivateAuthorizedPlatform(Long authId); + + AuthPlatformVO getAuthorizedPlatform(Long authId); } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java index 7a584229..cfbb9d5f 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/ChatbotServiceImpl.java @@ -274,4 +274,17 @@ public ChatThreadVO updateChatThread(ChatThreadDTO chatThreadDTO) { return ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO); } + + @Override + public ChatThreadVO getChatThread(Long threadId) { + ChatThreadPO chatThreadPO = chatThreadDao.findById(threadId); + if (chatThreadPO == null || chatThreadPO.getIsDeleted()) { + throw new ApiException(ApiExceptionEnum.CHAT_THREAD_NOT_FOUND); + } + Long userId = SessionUserHolder.getUserId(); + if (!chatThreadPO.getUserId().equals(userId)) { + throw new ApiException(ApiExceptionEnum.PERMISSION_DENIED); + } + return ChatThreadConverter.INSTANCE.fromPO2VO(chatThreadPO); + } } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LLMConfigServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LLMConfigServiceImpl.java index fabbff7f..6632a9a0 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LLMConfigServiceImpl.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/LLMConfigServiceImpl.java @@ -317,4 +317,14 @@ public boolean deactivateAuthorizedPlatform(Long authId) { } return true; } + + @Override + public AuthPlatformVO getAuthorizedPlatform(Long authId) { + AuthPlatformPO authPlatformPO = authPlatformDao.findById(authId); + if (authPlatformPO == null || authPlatformPO.getIsDeleted()) { + throw new ApiException(ApiExceptionEnum.PLATFORM_NOT_FOUND); + } + return AuthPlatformConverter.INSTANCE.fromPO2VO( + authPlatformPO, platformDao.findById(authPlatformPO.getPlatformId())); + } }