mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:38:13 +00:00
[feature][chat]Add deleteQuery API to support try-again feature.#1808
This commit is contained in:
@@ -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<ChatQueryDO> pageInfo =
|
||||
PageHelper.startPage(pageQueryInfoReq.getCurrent(), pageQueryInfoReq.getPageSize())
|
||||
@@ -95,6 +96,7 @@ public class ChatQueryRepositoryImpl implements ChatQueryRepository {
|
||||
QueryWrapper<ChatQueryDO> 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) {
|
||||
|
||||
@@ -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<ChatDO> getAllConversions(
|
||||
public List<ChatDO> 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) {
|
||||
|
||||
@@ -43,6 +43,8 @@ public interface ChatManageService {
|
||||
|
||||
int updateQuery(ChatQueryDO chatQueryDO);
|
||||
|
||||
void deleteQuery(Long queryId);
|
||||
|
||||
void updateParseCostTime(ParseResp parseResp);
|
||||
|
||||
List<ChatParseDO> batchAddParse(ChatParseReq chatParseReq, ParseResp parseResult);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user