Skip to content

Commit

Permalink
add detail api for llm
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Nov 12, 2024
1 parent 04875b8 commit 7f17e14
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ public ResponseEntity<Boolean> 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<ChatThreadVO> 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<List<ChatThreadVO>> getAllChatThreads() {
return ResponseEntity.success(chatbotService.getAllChatThreads());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<PlatformVO>> platforms() {
return ResponseEntity.success(llmConfigService.platforms());
Expand All @@ -62,7 +62,7 @@ public ResponseEntity<List<PlatformAuthCredentialVO>> 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<List<AuthPlatformVO>> authorizedPlatforms() {
return ResponseEntity.success(llmConfigService.authorizedPlatforms());
Expand Down Expand Up @@ -91,6 +91,12 @@ public ResponseEntity<AuthPlatformVO> updateAuthorizedPlatform(
return ResponseEntity.success(llmConfigService.updateAuthorizedPlatform(authPlatformDTO));
}

@Operation(summary = "get auth platform", description = "Get authorized platforms")
@GetMapping("/auth-platforms/{authId}")
public ResponseEntity<AuthPlatformVO> 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<Boolean> deleteAuthorizedPlatform(@PathVariable Long authId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ public interface ChatbotService {
List<ChatMessageVO> history(Long threadId);

ChatThreadVO updateChatThread(ChatThreadDTO chatThreadDTO);

ChatThreadVO getChatThread(Long threadId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ public interface LLMConfigService {
boolean activateAuthorizedPlatform(Long authId);

boolean deactivateAuthorizedPlatform(Long authId);

AuthPlatformVO getAuthorizedPlatform(Long authId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}

0 comments on commit 7f17e14

Please sign in to comment.