(fix)(Chat) Fix chat sample result save failed (#1261)

Co-authored-by: lxwcodemonkey
This commit is contained in:
LXW
2024-06-28 11:19:53 +08:00
committed by GitHub
parent 28f95ddf9e
commit 26cd73518d
6 changed files with 41 additions and 50 deletions

View File

@@ -3,8 +3,6 @@ package com.tencent.supersonic.demo;
import com.google.common.collect.Lists;
import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.auth.api.authorization.service.AuthService;
import com.tencent.supersonic.chat.api.pojo.request.ChatExecuteReq;
import com.tencent.supersonic.chat.api.pojo.request.ChatParseReq;
import com.tencent.supersonic.chat.server.service.AgentService;
import com.tencent.supersonic.chat.server.service.ChatManageService;
import com.tencent.supersonic.chat.server.service.ChatService;
@@ -21,7 +19,6 @@ import com.tencent.supersonic.headless.api.pojo.response.DatabaseResp;
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
import com.tencent.supersonic.headless.api.pojo.response.ModelResp;
import com.tencent.supersonic.headless.api.pojo.response.ParseResp;
import com.tencent.supersonic.headless.server.pojo.MetaFilter;
import com.tencent.supersonic.headless.server.web.service.CanvasService;
import com.tencent.supersonic.headless.server.web.service.DataSetService;
@@ -155,28 +152,6 @@ public abstract class S2BaseDemo implements CommandLineRunner {
return dataSetModelConfigs;
}
protected void parseAndExecute(int chatId, int agentId, String queryText) throws Exception {
ChatParseReq chatParseReq = new ChatParseReq();
chatParseReq.setQueryText(queryText);
chatParseReq.setChatId(chatId);
chatParseReq.setAgentId(agentId);
chatParseReq.setUser(User.getFakeUser());
ParseResp parseResp = chatService.performParsing(chatParseReq);
if (CollectionUtils.isEmpty(parseResp.getSelectedParses())) {
log.info("parseResp.getSelectedParses() is empty");
return;
}
ChatExecuteReq executeReq = new ChatExecuteReq();
executeReq.setQueryId(parseResp.getQueryId());
executeReq.setParseId(parseResp.getSelectedParses().get(0).getId());
executeReq.setQueryText(queryText);
executeReq.setChatId(parseResp.getChatId());
executeReq.setUser(User.getFakeUser());
executeReq.setAgentId(agentId);
executeReq.setSaveAnswer(true);
chatService.performExecution(executeReq);
}
protected void addTag(Long itemId, TagDefineType tagDefineType) {
TagReq tagReq = new TagReq();
tagReq.setTagDefineType(tagDefineType);

View File

@@ -132,15 +132,15 @@ public class S2VisitsDemo extends S2BaseDemo {
return true;
}
public void addSampleChats(Integer agentId) throws Exception {
public void addSampleChats(Integer agentId) {
Long chatId = chatManageService.addChat(user, "样例对话1", agentId);
parseAndExecute(chatId.intValue(), agentId, "超音数 访问次数");
parseAndExecute(chatId.intValue(), agentId, "按部门统计");
parseAndExecute(chatId.intValue(), agentId, "查询近30天");
parseAndExecute(chatId.intValue(), agentId, "alice 停留时长");
parseAndExecute(chatId.intValue(), agentId, "对比alice和lucy的访问次数");
parseAndExecute(chatId.intValue(), agentId, "访问次数最高的部门");
chatService.parseAndExecute(chatId.intValue(), agentId, "超音数 访问次数");
chatService.parseAndExecute(chatId.intValue(), agentId, "按部门统计");
chatService.parseAndExecute(chatId.intValue(), agentId, "查询近30天");
chatService.parseAndExecute(chatId.intValue(), agentId, "alice 停留时长");
chatService.parseAndExecute(chatId.intValue(), agentId, "对比alice和lucy的访问次数");
chatService.parseAndExecute(chatId.intValue(), agentId, "访问次数最高的部门");
}
private Integer addAgent(long dataSetId) {