mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-28 20:04:27 +08:00
headless integrates knowledge (#722)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.tencent.supersonic.chat;
|
||||
|
||||
import com.tencent.supersonic.BaseApplication;
|
||||
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.ExecuteQueryReq;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryReq;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tencent.supersonic.chat;
|
||||
|
||||
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.QueryResult;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tencent.supersonic.chat.mapper;
|
||||
|
||||
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryReq;
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.tencent.supersonic.headless;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.tencent.supersonic.common.pojo.enums.StatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TaskStatusEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.TypeEnums;
|
||||
import com.tencent.supersonic.common.util.JsonUtil;
|
||||
import com.tencent.supersonic.headless.api.pojo.ItemValueConfig;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.DictSingleTaskReq;
|
||||
import com.tencent.supersonic.headless.server.persistence.dataobject.DictConfDO;
|
||||
import com.tencent.supersonic.headless.server.persistence.mapper.DictConfMapper;
|
||||
import com.tencent.supersonic.headless.server.service.DictTaskService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class DictTest extends BaseTest {
|
||||
@Autowired
|
||||
private DictConfMapper confMapper;
|
||||
|
||||
@Autowired
|
||||
private DictTaskService taskService;
|
||||
|
||||
@Test
|
||||
public void insertConf() {
|
||||
DictConfDO confDO = new DictConfDO();
|
||||
Date createAt = new Date();
|
||||
confDO.setType(TypeEnums.DIMENSION.name());
|
||||
confDO.setItemId(1L);
|
||||
confDO.setConfig(JsonUtil.toString(new ItemValueConfig()));
|
||||
confDO.setStatus(StatusEnum.ONLINE.getStatus());
|
||||
confDO.setCreatedAt(createAt);
|
||||
confDO.setCreatedBy("admin");
|
||||
confMapper.insert(confDO);
|
||||
DictConfDO confDODb = confMapper.selectById(1L);
|
||||
System.out.println(confDODb.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void editConf() {
|
||||
DictConfDO confDO = new DictConfDO();
|
||||
Date createAt = new Date();
|
||||
confDO.setType(TypeEnums.DIMENSION.name());
|
||||
confDO.setItemId(3L);
|
||||
ItemValueConfig config = new ItemValueConfig();
|
||||
config.setMetricId(4L);
|
||||
config.setBlackList(new ArrayList<>(Arrays.asList("1", "3")));
|
||||
config.setWhiteList(new ArrayList<>(Arrays.asList("2", "4")));
|
||||
confDO.setConfig(JsonUtil.toString(config));
|
||||
confDO.setStatus(TaskStatusEnum.PENDING.getStatus());
|
||||
confDO.setCreatedAt(createAt);
|
||||
confDO.setCreatedBy("admin");
|
||||
confMapper.insert(confDO);
|
||||
DictConfDO confDODb = confMapper.selectById(1L);
|
||||
|
||||
confDO.setStatus(StatusEnum.OFFLINE.getStatus());
|
||||
// config.setMetricId(3L);
|
||||
config.setBlackList(new ArrayList<>(Arrays.asList("p2")));
|
||||
config.setWhiteList(new ArrayList<>(Arrays.asList("p10", "p12")));
|
||||
confDODb.setConfig(JsonUtil.toString(config));
|
||||
confMapper.updateById(confDODb);
|
||||
DictConfDO confDODb1 = confMapper.selectById(1L);
|
||||
System.out.println(confDODb1.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBatchInsert() {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
insertConf();
|
||||
}
|
||||
QueryWrapper<DictConfDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(DictConfDO::getType, "DIMENSION");
|
||||
List<DictConfDO> dictConfDOList = confMapper.selectList(wrapper);
|
||||
System.out.println(dictConfDOList);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddTask() {
|
||||
editConf();
|
||||
DictConfDO confDODb = confMapper.selectById(1L);
|
||||
DictSingleTaskReq dictTask = DictSingleTaskReq.builder().itemId(confDODb.getItemId())
|
||||
.type(TypeEnums.DIMENSION).build();
|
||||
taskService.addDictTask(dictTask, null);
|
||||
DictSingleTaskReq taskReq = DictSingleTaskReq.builder().itemId(3L).type(TypeEnums.DIMENSION).build();
|
||||
taskService.deleteDictTask(taskReq, null);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.tencent.supersonic.util;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryReq;
|
||||
import com.tencent.supersonic.chat.core.agent.Agent;
|
||||
|
||||
@@ -27,8 +27,8 @@ com.tencent.supersonic.chat.server.processor.parse.ParseResultProcessor=\
|
||||
com.tencent.supersonic.chat.server.processor.parse.RespBuildProcessor, \
|
||||
com.tencent.supersonic.chat.server.processor.parse.QueryRecommendProcessor
|
||||
|
||||
com.tencent.supersonic.chat.core.knowledge.semantic.SemanticInterpreter=\
|
||||
com.tencent.supersonic.chat.core.knowledge.semantic.LocalSemanticInterpreter
|
||||
com.tencent.supersonic.chat.core.query.semantic.SemanticInterpreter=\
|
||||
com.tencent.supersonic.chat.core.query.semantic.LocalSemanticInterpreter
|
||||
|
||||
com.tencent.supersonic.chat.core.parser.sql.llm.ViewResolver=\
|
||||
com.tencent.supersonic.chat.core.parser.sql.llm.HeuristicViewResolver
|
||||
|
||||
@@ -394,19 +394,30 @@ CREATE TABLE IF NOT EXISTS `singer` (
|
||||
);
|
||||
COMMENT ON TABLE singer IS 'singer_info';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `s2_dictionary_conf` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`description` varchar(255) ,
|
||||
`type` varchar(255) NOT NULL ,
|
||||
`item_id` INT NOT NULL , -- task Request Parameters md5
|
||||
`config` LONGVARCHAR , -- remark related information
|
||||
`status` varchar(255) NOT NULL , -- the final status of the task
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
|
||||
`created_by` varchar(100) NOT NULL ,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_dictionary_conf IS 'dictionary conf information table';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `s2_dictionary_task` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL , -- task name
|
||||
`description` varchar(255) ,
|
||||
`command`LONGVARCHAR NOT NULL , -- task Request Parameters
|
||||
`command_md5` varchar(255) NOT NULL , -- task Request Parameters md5
|
||||
`status` INT NOT NULL , -- the final status of the task
|
||||
`dimension_ids` varchar(500) NULL ,
|
||||
`type` varchar(255) NOT NULL ,
|
||||
`item_id` INT NOT NULL , -- task Request Parameters md5
|
||||
`config` LONGVARCHAR , -- remark related information
|
||||
`status` varchar(255) NOT NULL , -- the final status of the task
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
|
||||
`created_by` varchar(100) NOT NULL ,
|
||||
`progress` DOUBLE default 0.00 , -- task real-time progress
|
||||
`elapsed_ms` bigINT DEFAULT NULL , -- the task takes time in milliseconds
|
||||
`message` LONGVARCHAR , -- remark related information
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
COMMENT ON TABLE s2_dictionary_task IS 'dictionary task information table';
|
||||
|
||||
Reference in New Issue
Block a user