mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
(feature) (chat) add llm examples in chat config (#379)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -32,6 +32,11 @@ public class ChatConfigBaseReq {
|
||||
*/
|
||||
private List<RecommendedQuestionReq> recommendedQuestions;
|
||||
|
||||
/**
|
||||
* the llm examples about the model
|
||||
*/
|
||||
private String llmExamples;
|
||||
|
||||
/**
|
||||
* available status
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,8 @@ public class ChatConfigResp {
|
||||
|
||||
private List<RecommendedQuestionReq> recommendedQuestions;
|
||||
|
||||
private String llmExamples;
|
||||
|
||||
/**
|
||||
* available status
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,8 @@ public class ChatConfigDO {
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String llmExamples;
|
||||
|
||||
/**
|
||||
* record info
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<result column="chat_agg_config" property="chatAggConfig"/>
|
||||
<result column="recommended_questions" property="recommendedQuestions"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="llm_examples" property="llmExamples"/>
|
||||
<result column="created_by" property="createdBy"/>
|
||||
<result column="updated_by" property="updatedBy"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
@@ -24,11 +25,11 @@
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
insert into s2_chat_config
|
||||
(
|
||||
model_id, `chat_detail_config`, chat_agg_config, recommended_questions, status, created_by, updated_by, created_at, updated_at
|
||||
model_id, `chat_detail_config`, chat_agg_config, recommended_questions, status, llm_examples, created_by, updated_by, created_at, updated_at
|
||||
)
|
||||
values
|
||||
(
|
||||
#{modelId}, #{chatDetailConfig}, #{chatAggConfig}, #{recommendedQuestions}, #{status}, #{createdBy}, #{updatedBy}, #{createdAt}, #{updatedAt}
|
||||
#{modelId}, #{chatDetailConfig}, #{chatAggConfig}, #{recommendedQuestions}, #{status}, #{llmExamples}, #{createdBy}, #{updatedBy}, #{createdAt}, #{updatedAt}
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -52,6 +53,9 @@
|
||||
<if test="updatedBy != null and updatedBy != ''">
|
||||
updated_by = #{updatedBy} ,
|
||||
</if>
|
||||
<if test="llmExamples != null and llmExamples != ''">
|
||||
llm_examples = #{llmExamples} ,
|
||||
</if>
|
||||
</set>
|
||||
|
||||
<where>
|
||||
|
||||
@@ -34,6 +34,8 @@ public class SysParameter {
|
||||
public void init() {
|
||||
parameters = Lists.newArrayList();
|
||||
admins = Lists.newArrayList("admin");
|
||||
parameters.add(new Parameter("llm.model.name", "gpt4", "模型名称", "string"));
|
||||
parameters.add(new Parameter("llm.api.key", "sk-afdasdasd", "模型密钥", "string"));
|
||||
parameters.add(new Parameter("one.detection.size", "8", "一次探测个数", "number"));
|
||||
parameters.add(new Parameter("one.detection.max.size", "20", "阈值", "number"));
|
||||
parameters.add(new Parameter("metric.dimension.min.threshold", "0.3", "指标名、维度名最小文本相似度", "number"));
|
||||
@@ -44,6 +46,7 @@ public class SysParameter {
|
||||
parameters.add(new Parameter("embedding.mapper.batch", "0.3", "批量向量召回文本请求个数", "number"));
|
||||
parameters.add(new Parameter("embedding.mapper.number", "0.3", "批量向量召回文本返回结果个数", "number"));
|
||||
parameters.add(new Parameter("embedding.mapper.distance.threshold", "0.3", "Mapper阶段向量召回相似度阈值", "number"));
|
||||
parameters.add(new Parameter("use.s2SQL.switch", "true", "是否打开S2SQL开关", "bool"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SysParameterController {
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
SysParameter get() {
|
||||
public SysParameter get() {
|
||||
return sysParameterService.getSysParameter();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.tencent.supersonic.chat.service.impl;
|
||||
package com.tencent.supersonic.common.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -99,11 +99,11 @@ public class ConfigureDemo implements ApplicationListener<ApplicationReadyEvent>
|
||||
parseAndExecute(2, "访问次数最高的部门");
|
||||
}
|
||||
|
||||
public void addChatParameter() {
|
||||
SysParameter chatParameter = new SysParameter();
|
||||
chatParameter.setId(1);
|
||||
chatParameter.init();
|
||||
sysParameterService.save(chatParameter);
|
||||
public void addSysParameter() {
|
||||
SysParameter sysParameter = new SysParameter();
|
||||
sysParameter.setId(1);
|
||||
sysParameter.init();
|
||||
sysParameterService.save(sysParameter);
|
||||
}
|
||||
|
||||
public void addDemoChatConfig_1() {
|
||||
@@ -306,7 +306,7 @@ public class ConfigureDemo implements ApplicationListener<ApplicationReadyEvent>
|
||||
return;
|
||||
}
|
||||
try {
|
||||
addChatParameter();
|
||||
addSysParameter();
|
||||
addDemoChatConfig_1();
|
||||
addDemoChatConfig_2();
|
||||
addPlugin_1();
|
||||
|
||||
@@ -75,6 +75,7 @@ CREATE TABLE IF NOT EXISTS `s2_chat_config` (
|
||||
`created_by` varchar(100) NOT NULL ,
|
||||
`updated_by` varchar(100) NOT NULL ,
|
||||
`status` INT NOT NULL DEFAULT '0' , -- domain extension information status : 0 is normal, 1 is off the shelf, 2 is deleted
|
||||
`llm_examples` TEXT,
|
||||
PRIMARY KEY (`id`)
|
||||
) ;
|
||||
COMMENT ON TABLE s2_chat_config IS 'chat config information table ';
|
||||
|
||||
@@ -63,6 +63,7 @@ CREATE TABLE `s2_chat_config` (
|
||||
`created_by` varchar(100) NOT NULL COMMENT '创建人',
|
||||
`updated_by` varchar(100) NOT NULL COMMENT '更新人',
|
||||
`status` int(10) NOT NULL COMMENT '主题域扩展信息状态, 0-删除,1-生效',
|
||||
`llm_examples` text COMMENT 'llm examples',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='主题域扩展信息表';
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ CREATE TABLE IF NOT EXISTS `s2_chat_config` (
|
||||
`created_by` varchar(100) NOT NULL ,
|
||||
`updated_by` varchar(100) NOT NULL ,
|
||||
`status` INT NOT NULL DEFAULT '0' , -- domain extension information status : 0 is normal, 1 is off the shelf, 2 is deleted
|
||||
`llm_examples` TEXT,
|
||||
PRIMARY KEY (`id`)
|
||||
) ;
|
||||
COMMENT ON TABLE s2_chat_config IS 'chat config information table ';
|
||||
|
||||
@@ -28,6 +28,8 @@ public class Measure {
|
||||
|
||||
private Long datasourceId;
|
||||
|
||||
private String datasourceName;
|
||||
|
||||
public Measure(String name, String bizName, String agg, Integer isCreateMetric) {
|
||||
this.name = name;
|
||||
this.agg = agg;
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.tencent.supersonic.common.pojo.DataFormat;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.DrillDownDimension;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.Measure;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.MetricTypeParams;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.RelateDimension;
|
||||
import com.tencent.supersonic.semantic.api.model.pojo.SchemaItem;
|
||||
@@ -72,4 +73,11 @@ public class MetricResp extends SchemaItem {
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
public List<Measure> getMeasures() {
|
||||
if (typeParams == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return typeParams.getMeasures();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,11 @@ import com.tencent.supersonic.semantic.api.model.pojo.MetricTypeParams;
|
||||
import com.tencent.supersonic.semantic.api.model.request.MetaBatchReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.MetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.request.PageMetricReq;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DatasourceResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.DatasourceService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.MetricDO;
|
||||
@@ -57,6 +59,8 @@ public class MetricServiceImpl implements MetricService {
|
||||
|
||||
private DomainService domainService;
|
||||
|
||||
private DatasourceService datasourceService;
|
||||
|
||||
private ChatGptHelper chatGptHelper;
|
||||
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
@@ -64,11 +68,13 @@ public class MetricServiceImpl implements MetricService {
|
||||
public MetricServiceImpl(MetricRepository metricRepository,
|
||||
ModelService modelService,
|
||||
DomainService domainService,
|
||||
DatasourceService datasourceService,
|
||||
ChatGptHelper chatGptHelper,
|
||||
ApplicationEventPublisher eventPublisher) {
|
||||
this.domainService = domainService;
|
||||
this.metricRepository = metricRepository;
|
||||
this.modelService = modelService;
|
||||
this.datasourceService = datasourceService;
|
||||
this.chatGptHelper = chatGptHelper;
|
||||
this.eventPublisher = eventPublisher;
|
||||
}
|
||||
@@ -222,6 +228,7 @@ public class MetricServiceImpl implements MetricService {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public MetricResp getMetric(Long modelId, String bizName) {
|
||||
MetricFilter metricFilter = new MetricFilter();
|
||||
@@ -250,7 +257,20 @@ public class MetricServiceImpl implements MetricService {
|
||||
if (metricDO == null) {
|
||||
return null;
|
||||
}
|
||||
return MetricConverter.convert2MetricResp(metricDO, new HashMap<>());
|
||||
MetricResp metricResp = MetricConverter.convert2MetricResp(metricDO, new HashMap<>());
|
||||
List<Measure> measures = metricResp.getMeasures();
|
||||
if (CollectionUtils.isEmpty(measures)) {
|
||||
return metricResp;
|
||||
}
|
||||
Map<Long, DatasourceResp> datasourceResps = datasourceService.getDatasourceList().stream()
|
||||
.collect(Collectors.toMap(DatasourceResp::getId, datasourceResp -> datasourceResp));
|
||||
measures.forEach(measure -> {
|
||||
DatasourceResp datasourceResp = datasourceResps.get(measure.getDatasourceId());
|
||||
if (datasourceResp != null) {
|
||||
measure.setDatasourceName(datasourceResp.getName());
|
||||
}
|
||||
});
|
||||
return metricResp;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user