| | |
| | | package com.vincent.rsf.server.ai.controller; |
| | | |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.server.ai.dto.AiChatSessionPinRequest; |
| | | import com.vincent.rsf.server.ai.dto.AiChatSessionRenameRequest; |
| | | import com.vincent.rsf.server.ai.dto.AiChatRequest; |
| | | import com.vincent.rsf.server.ai.service.AiChatService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | |
| | | |
| | | @PreAuthorize("isAuthenticated()") |
| | | @GetMapping("/ai/chat/sessions") |
| | | public R sessions(@RequestParam(required = false) String promptCode) { |
| | | return R.ok().add(aiChatService.listSessions(promptCode, getLoginUserId(), getTenantId())); |
| | | public R sessions(@RequestParam(required = false) String promptCode, |
| | | @RequestParam(required = false) String keyword) { |
| | | return R.ok().add(aiChatService.listSessions(promptCode, keyword, getLoginUserId(), getTenantId())); |
| | | } |
| | | |
| | | @PreAuthorize("isAuthenticated()") |
| | |
| | | } |
| | | |
| | | @PreAuthorize("isAuthenticated()") |
| | | @PostMapping("/ai/chat/session/rename/{sessionId}") |
| | | public R renameSession(@PathVariable Long sessionId, @RequestBody AiChatSessionRenameRequest request) { |
| | | return R.ok("Update Success").add(aiChatService.renameSession(sessionId, request, getLoginUserId(), getTenantId())); |
| | | } |
| | | |
| | | @PreAuthorize("isAuthenticated()") |
| | | @PostMapping("/ai/chat/session/pin/{sessionId}") |
| | | public R pinSession(@PathVariable Long sessionId, @RequestBody AiChatSessionPinRequest request) { |
| | | return R.ok("Update Success").add(aiChatService.pinSession(sessionId, request, getLoginUserId(), getTenantId())); |
| | | } |
| | | |
| | | @PreAuthorize("isAuthenticated()") |
| | | @PostMapping("/ai/chat/session/memory/clear/{sessionId}") |
| | | public R clearSessionMemory(@PathVariable Long sessionId) { |
| | | aiChatService.clearSessionMemory(sessionId, getLoginUserId(), getTenantId()); |
| | | return R.ok("Clear Success").add(sessionId); |
| | | } |
| | | |
| | | @PreAuthorize("isAuthenticated()") |
| | | @PostMapping("/ai/chat/session/memory/retain-latest/{sessionId}") |
| | | public R retainLatestRound(@PathVariable Long sessionId) { |
| | | aiChatService.retainLatestRound(sessionId, getLoginUserId(), getTenantId()); |
| | | return R.ok("Retain Success").add(sessionId); |
| | | } |
| | | |
| | | @PreAuthorize("isAuthenticated()") |
| | | @PostMapping(value = "/ai/chat/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) |
| | | public SseEmitter stream(@RequestBody AiChatRequest request) { |
| | | String requestId = StringUtils.hasText(request.getRequestId()) |