diff --git a/chat/server/src/main/java/com/tencent/supersonic/chat/server/persistence/repository/impl/ChatQueryRepositoryImpl.java b/chat/server/src/main/java/com/tencent/supersonic/chat/server/persistence/repository/impl/ChatQueryRepositoryImpl.java index 1c03a9af8..bc2454b8a 100644 --- a/chat/server/src/main/java/com/tencent/supersonic/chat/server/persistence/repository/impl/ChatQueryRepositoryImpl.java +++ b/chat/server/src/main/java/com/tencent/supersonic/chat/server/persistence/repository/impl/ChatQueryRepositoryImpl.java @@ -64,6 +64,7 @@ public class ChatQueryRepositoryImpl implements ChatQueryRepository { queryWrapper.lambda().isNotNull(ChatQueryDO::getQueryResult); queryWrapper.lambda().ne(ChatQueryDO::getQueryResult, ""); queryWrapper.lambda().orderByDesc(ChatQueryDO::getQuestionId); + queryWrapper.lambda().eq(ChatQueryDO::getQueryState, 1); PageInfo pageInfo = PageHelper.startPage(pageQueryInfoReq.getCurrent(), pageQueryInfoReq.getPageSize()) @@ -95,6 +96,7 @@ public class ChatQueryRepositoryImpl implements ChatQueryRepository { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(ChatQueryDO::getChatId, chatId); queryWrapper.lambda().orderByDesc(ChatQueryDO::getQuestionId); + queryWrapper.lambda().eq(ChatQueryDO::getQueryState, 1); return chatQueryDOMapper.selectList(queryWrapper).stream().map(q -> convertTo(q)) .collect(Collectors.toList()); } @@ -132,6 +134,7 @@ public class ChatQueryRepositoryImpl implements ChatQueryRepository { chatQueryDO.setQueryText(chatParseReq.getQueryText()); chatQueryDO.setAgentId(chatParseReq.getAgentId()); chatQueryDO.setQueryResult(""); + chatQueryDO.setQueryState(1); try { chatQueryDOMapper.insert(chatQueryDO); } catch (Exception e) { diff --git a/chat/server/src/main/java/com/tencent/supersonic/chat/server/rest/ChatController.java b/chat/server/src/main/java/com/tencent/supersonic/chat/server/rest/ChatController.java index c79ac2795..ecbb8680f 100644 --- a/chat/server/src/main/java/com/tencent/supersonic/chat/server/rest/ChatController.java +++ b/chat/server/src/main/java/com/tencent/supersonic/chat/server/rest/ChatController.java @@ -11,13 +11,7 @@ import com.tencent.supersonic.chat.api.pojo.response.ShowCaseResp; import com.tencent.supersonic.chat.server.persistence.dataobject.ChatDO; import com.tencent.supersonic.chat.server.service.ChatManageService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -37,7 +31,7 @@ public class ChatController { } @GetMapping("/getAll") - public List getAllConversions( + public List getAllChats( @RequestParam(value = "agentId", required = false) Integer agentId, HttpServletRequest request, HttpServletResponse response) { String userName = UserHolder.findUser(request, response).getName(); @@ -45,14 +39,14 @@ public class ChatController { } @PostMapping("/delete") - public Boolean deleteConversion(@RequestParam(value = "chatId") long chatId, + public Boolean deleteChat(@RequestParam(value = "chatId") long chatId, HttpServletRequest request, HttpServletResponse response) { String userName = UserHolder.findUser(request, response).getName(); return chatService.deleteChat(chatId, userName); } @PostMapping("/updateChatName") - public Boolean updateConversionName(@RequestParam(value = "chatId") Long chatId, + public Boolean updateChatName(@RequestParam(value = "chatId") Long chatId, @RequestParam(value = "chatName") String chatName, HttpServletRequest request, HttpServletResponse response) { String userName = UserHolder.findUser(request, response).getName(); @@ -67,7 +61,7 @@ public class ChatController { } @PostMapping("/updateChatIsTop") - public Boolean updateConversionIsTop(@RequestParam(value = "chatId") Long chatId, + public Boolean updateChatIsTop(@RequestParam(value = "chatId") Long chatId, @RequestParam(value = "isTop") int isTop) { return chatService.updateChatIsTop(chatId, isTop); } @@ -85,6 +79,12 @@ public class ChatController { return chatService.getChatQuery(queryId); } + @DeleteMapping("/{queryId}") + public boolean deleteChatQuery(@PathVariable(value = "queryId") Long queryId) { + chatService.deleteQuery(queryId); + return true; + } + @PostMapping("/queryShowCase") public ShowCaseResp queryShowCase(@RequestBody PageQueryInfoReq pageQueryInfoCommand, @RequestParam(value = "agentId") int agentId) { diff --git a/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/ChatManageService.java b/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/ChatManageService.java index d01862ba9..96904abbb 100644 --- a/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/ChatManageService.java +++ b/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/ChatManageService.java @@ -43,6 +43,8 @@ public interface ChatManageService { int updateQuery(ChatQueryDO chatQueryDO); + void deleteQuery(Long queryId); + void updateParseCostTime(ParseResp parseResp); List batchAddParse(ChatParseReq chatParseReq, ParseResp parseResult); diff --git a/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/impl/ChatManageServiceImpl.java b/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/impl/ChatManageServiceImpl.java index a40cd3807..4ffe8f609 100644 --- a/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/impl/ChatManageServiceImpl.java +++ b/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/impl/ChatManageServiceImpl.java @@ -25,11 +25,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -187,6 +183,15 @@ public class ChatManageServiceImpl implements ChatManageService { return chatQueryRepository.updateChatQuery(chatQueryDO); } + @Override + public void deleteQuery(Long queryId) { + ChatQueryDO chatQuery = chatQueryRepository.getChatQueryDO(queryId); + if (Objects.nonNull(chatQuery)) { + chatQuery.setQueryState(0); + chatQueryRepository.updateChatQuery(chatQuery); + } + } + @Override public void updateParseCostTime(ParseResp parseResp) { ChatQueryDO chatQueryDO = chatQueryRepository.getChatQueryDO(parseResp.getQueryId()); diff --git a/launchers/standalone/src/main/resources/config.update/sql-update.sql b/launchers/standalone/src/main/resources/config.update/sql-update.sql index ac219e399..47555be9d 100644 --- a/launchers/standalone/src/main/resources/config.update/sql-update.sql +++ b/launchers/standalone/src/main/resources/config.update/sql-update.sql @@ -389,9 +389,9 @@ ALTER TABLE s2_agent RENAME COLUMN config TO tool_config; ALTER TABLE s2_agent RENAME COLUMN model_config TO chat_model_config; --20241011 -ALTER TABLE s2_agent DROP COLUMN prompt_config; -ALTER TABLE s2_agent DROP COLUMN multi_turn_config; -ALTER TABLE s2_agent DROP COLUMN enable_memory_review; +ALTER TABLE s2_agent DROP COLUMN IF EXISTS `prompt_config`; +ALTER TABLE s2_agent DROP COLUMN IF EXISTS `multi_turn_config`; +ALTER TABLE s2_agent DROP COLUMN IF EXISTS `enable_memory_review`; --20241012 alter table s2_agent add column `enable_feedback` tinyint DEFAULT 1; \ No newline at end of file