Commit 6a719e97 authored by alex yao's avatar alex yao

feat: Agent应用,模型配置添加temperature字段

parent 46c7bd0c
...@@ -19,7 +19,7 @@ public interface AgentApplicationInfoService { ...@@ -19,7 +19,7 @@ public interface AgentApplicationInfoService {
* 应用预览 * 应用预览
*/ */
String callAgentApplication(String identifier, String largeModel, String[] unitIds, String agentSystem, String callAgentApplication(String identifier, String largeModel, String[] unitIds, String agentSystem,
Integer[] knowledgeIds, Integer communicationTurn, Float topP, Integer[] knowledgeIds, Integer communicationTurn, Float topP, Float temperature,
List<Message> messages, List<Tool> tools, HttpServletResponse httpServletResponse) throws Exception; List<Message> messages, List<Tool> tools, HttpServletResponse httpServletResponse) throws Exception;
/** /**
......
...@@ -102,7 +102,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -102,7 +102,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
} }
@Override @Override
public String callAgentApplication(String identifier, String largeModel, String[] unitIds, String agentSystem, Integer[] kdIds, Integer communicationTurn, Float topP, List<Message> messages, List<Tool> tools, HttpServletResponse httpServletResponse) throws Exception { public String callAgentApplication(String identifier, String largeModel, String[] unitIds, String agentSystem, Integer[] kdIds, Integer communicationTurn, Float topP, Float temperature, List<Message> messages, List<Tool> tools, HttpServletResponse httpServletResponse) throws Exception {
logger.info("--------- Call Agent Application large model:{},unitIds:{},agentSystem:{},knowledgeIds:{}" + " communicationTurn:{},topP:{},messages:{}--------------", largeModel, unitIds, agentSystem, kdIds, communicationTurn, topP, messages); logger.info("--------- Call Agent Application large model:{},unitIds:{},agentSystem:{},knowledgeIds:{}" + " communicationTurn:{},topP:{},messages:{}--------------", largeModel, unitIds, agentSystem, kdIds, communicationTurn, topP, messages);
String model = modelConvert(largeModel); String model = modelConvert(largeModel);
......
...@@ -58,6 +58,7 @@ public class AgentApplicationInfoConvert { ...@@ -58,6 +58,7 @@ public class AgentApplicationInfoConvert {
} }
entity.setLargeModel(model.getLargeModel()); entity.setLargeModel(model.getLargeModel());
entity.setTopP(model.getTopP()); entity.setTopP(model.getTopP());
entity.setTemperature(model.getTemperature());
if (StringUtils.isNotBlank(model.getUnitIds())) { if (StringUtils.isNotBlank(model.getUnitIds())) {
entity.setUnitIds(JsonUtils.deSerialize(model.getUnitIds(), String[].class)); entity.setUnitIds(JsonUtils.deSerialize(model.getUnitIds(), String[].class));
} }
...@@ -98,6 +99,7 @@ public class AgentApplicationInfoConvert { ...@@ -98,6 +99,7 @@ public class AgentApplicationInfoConvert {
} }
model.setLargeModel(entity.getLargeModel()); model.setLargeModel(entity.getLargeModel());
model.setTopP(entity.getTopP()); model.setTopP(entity.getTopP());
model.setTemperature(entity.getTemperature());
if (ArrayUtils.isNotEmpty(entity.getUnitIds())) { if (ArrayUtils.isNotEmpty(entity.getUnitIds())) {
model.setUnitIds(JsonUtil.toJson(entity.getUnitIds())); model.setUnitIds(JsonUtil.toJson(entity.getUnitIds()));
} }
...@@ -137,6 +139,7 @@ public class AgentApplicationInfoConvert { ...@@ -137,6 +139,7 @@ public class AgentApplicationInfoConvert {
AgentApplicationCommModelConfig commModelConfig = new AgentApplicationCommModelConfig(); AgentApplicationCommModelConfig commModelConfig = new AgentApplicationCommModelConfig();
commModelConfig.setLargeModel(entity.getLargeModel()); commModelConfig.setLargeModel(entity.getLargeModel());
commModelConfig.setTopP(entity.getTopP()); commModelConfig.setTopP(entity.getTopP());
commModelConfig.setTemperature(entity.getTemperature());
commModelConfig.setCommunicationTurn(entity.getCommunicationTurn()); commModelConfig.setCommunicationTurn(entity.getCommunicationTurn());
AgentApplicationInfoDto dto = new AgentApplicationInfoDto(); AgentApplicationInfoDto dto = new AgentApplicationInfoDto();
...@@ -184,6 +187,7 @@ public class AgentApplicationInfoConvert { ...@@ -184,6 +187,7 @@ public class AgentApplicationInfoConvert {
if (ObjectUtil.isNotEmpty(dto.getCommModelConfig())) { if (ObjectUtil.isNotEmpty(dto.getCommModelConfig())) {
entity.setLargeModel(dto.getCommModelConfig().getLargeModel()); entity.setLargeModel(dto.getCommModelConfig().getLargeModel());
entity.setTopP(dto.getCommModelConfig().getTopP()); entity.setTopP(dto.getCommModelConfig().getTopP());
entity.setTemperature(dto.getCommModelConfig().getTemperature());
entity.setCommunicationTurn(dto.getCommModelConfig().getCommunicationTurn()); entity.setCommunicationTurn(dto.getCommModelConfig().getCommunicationTurn());
} }
...@@ -225,6 +229,7 @@ public class AgentApplicationInfoConvert { ...@@ -225,6 +229,7 @@ public class AgentApplicationInfoConvert {
} }
entity.setLargeModel(infoQueryItem.getLargeModel()); entity.setLargeModel(infoQueryItem.getLargeModel());
entity.setTopP(infoQueryItem.getTopP()); entity.setTopP(infoQueryItem.getTopP());
entity.setTemperature(infoQueryItem.getTemperature());
if (StringUtils.isNotBlank(infoQueryItem.getUnitIds())) { if (StringUtils.isNotBlank(infoQueryItem.getUnitIds())) {
entity.setUnitIds(JsonUtils.deSerialize(infoQueryItem.getUnitIds(), String[].class)); entity.setUnitIds(JsonUtils.deSerialize(infoQueryItem.getUnitIds(), String[].class));
} }
......
...@@ -46,6 +46,7 @@ public class BizAgentApplicationPublishConvert { ...@@ -46,6 +46,7 @@ public class BizAgentApplicationPublishConvert {
} }
entity.setLargeModel(model.getLargeModel()); entity.setLargeModel(model.getLargeModel());
entity.setTopP(model.getTopP()); entity.setTopP(model.getTopP());
entity.setTemperature(model.getTemperature());
if (StringUtils.isNotBlank(model.getUnitIds())) { if (StringUtils.isNotBlank(model.getUnitIds())) {
entity.setUnitIds(JsonUtils.deSerialize(model.getUnitIds(), String[].class)); entity.setUnitIds(JsonUtils.deSerialize(model.getUnitIds(), String[].class));
} }
...@@ -84,6 +85,7 @@ public class BizAgentApplicationPublishConvert { ...@@ -84,6 +85,7 @@ public class BizAgentApplicationPublishConvert {
} }
model.setLargeModel(entity.getLargeModel()); model.setLargeModel(entity.getLargeModel());
model.setTopP(entity.getTopP()); model.setTopP(entity.getTopP());
model.setTemperature(entity.getTemperature());
if (ArrayUtils.isNotEmpty(entity.getUnitIds())) { if (ArrayUtils.isNotEmpty(entity.getUnitIds())) {
model.setUnitIds(JsonUtil.toJson(entity.getUnitIds())); model.setUnitIds(JsonUtil.toJson(entity.getUnitIds()));
} }
...@@ -123,6 +125,7 @@ public class BizAgentApplicationPublishConvert { ...@@ -123,6 +125,7 @@ public class BizAgentApplicationPublishConvert {
AgentApplicationCommModelConfig commModelConfig = new AgentApplicationCommModelConfig(); AgentApplicationCommModelConfig commModelConfig = new AgentApplicationCommModelConfig();
commModelConfig.setLargeModel(entity.getLargeModel()); commModelConfig.setLargeModel(entity.getLargeModel());
commModelConfig.setTopP(entity.getTopP()); commModelConfig.setTopP(entity.getTopP());
commModelConfig.setTemperature(entity.getTemperature());
commModelConfig.setCommunicationTurn(entity.getCommunicationTurn()); commModelConfig.setCommunicationTurn(entity.getCommunicationTurn());
dto.setBaseInfo(baseInfo); dto.setBaseInfo(baseInfo);
...@@ -170,6 +173,7 @@ public class BizAgentApplicationPublishConvert { ...@@ -170,6 +173,7 @@ public class BizAgentApplicationPublishConvert {
if (ObjectUtil.isNotEmpty(dto.getCommModelConfig())) { if (ObjectUtil.isNotEmpty(dto.getCommModelConfig())) {
entity.setLargeModel(dto.getCommModelConfig().getLargeModel()); entity.setLargeModel(dto.getCommModelConfig().getLargeModel());
entity.setTopP(dto.getCommModelConfig().getTopP()); entity.setTopP(dto.getCommModelConfig().getTopP());
entity.setTemperature(dto.getCommModelConfig().getTemperature());
} }
entity.setUnitIds(dto.getUnitIds()); entity.setUnitIds(dto.getUnitIds());
......
...@@ -33,6 +33,20 @@ public class AgentApplicationCommModelConfig { ...@@ -33,6 +33,20 @@ public class AgentApplicationCommModelConfig {
this.topP = topP; this.topP = topP;
} }
/**
* temperature
* 对话模型温度配置 (0-1.0]
*/
private Float temperature;
public Float getTemperature() {
return temperature;
}
public void setTemperature(Float temperature) {
this.temperature = temperature;
}
/** /**
* communication_turn * communication_turn
* 对话上下文保存轮次 * 对话上下文保存轮次
......
package cn.com.poc.agent_application.entity; package cn.com.poc.agent_application.entity;
import javax.persistence.Column;
public class BizAgentApplicationPublishEntity { public class BizAgentApplicationPublishEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -234,6 +236,22 @@ public class BizAgentApplicationPublishEntity { ...@@ -234,6 +236,22 @@ public class BizAgentApplicationPublishEntity {
public void setTopP(java.lang.Float topP){ public void setTopP(java.lang.Float topP){
this.topP = topP; this.topP = topP;
} }
/** temperature
*对话模型 温度 [0-1.00]
*/
private java.lang.Float temperature;
public java.lang.Float getTemperature(){
return this.temperature;
}
public void setTemperature(java.lang.Float temperature){
this.temperature = temperature;
}
/** unit_ids /** unit_ids
*组件ID *组件ID
*/ */
......
...@@ -312,8 +312,27 @@ public class BizAgentApplicationInfoModel extends BaseModelClass implements Seri ...@@ -312,8 +312,27 @@ public class BizAgentApplicationInfoModel extends BaseModelClass implements Seri
this.topP = topP; this.topP = topP;
super.addValidField("topP"); super.addValidField("topP");
} }
/** temperature
*对话模型 温度 [0-1.00]
*/
private java.lang.Float temperature;
@Column(name = "temperature",length = 12)
public java.lang.Float getTemperature(){
return this.temperature;
}
public void setTemperature(java.lang.Float temperature){
this.temperature = temperature;
super.addValidField("temperature");
}
/** unit_ids /** unit_ids
*组件ID *组件ID
*/ */
......
...@@ -295,8 +295,25 @@ public class BizAgentApplicationPublishModel extends BaseModelClass implements S ...@@ -295,8 +295,25 @@ public class BizAgentApplicationPublishModel extends BaseModelClass implements S
this.topP = topP; this.topP = topP;
super.addValidField("topP"); super.addValidField("topP");
} }
/** temperature
*对话模型 温度 [0-1.00]
*/
private java.lang.Float temperature;
@Column(name = "temperature",length = 12)
public java.lang.Float getTemperature(){
return this.temperature;
}
public void setTemperature(java.lang.Float temperature){
this.temperature = temperature;
super.addValidField("temperature");
}
/** unit_ids /** unit_ids
*组件ID *组件ID
*/ */
......
...@@ -17,6 +17,7 @@ select distinct ...@@ -17,6 +17,7 @@ select distinct
knowledge_ids, knowledge_ids,
large_model, large_model,
top_p, top_p,
temperature,
unit_ids, unit_ids,
variable_structure, variable_structure,
is_long_memory, is_long_memory,
......
...@@ -284,6 +284,23 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri ...@@ -284,6 +284,23 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri
this.topP = topP; this.topP = topP;
} }
/** temperature
*对话模型 温度 [0-1.00]
*/
private java.lang.Float temperature;
@Column(name = "temperature")
public java.lang.Float getTemperature(){
return this.temperature;
}
public void setTemperature(java.lang.Float temperature){
this.temperature = temperature;
}
/** /**
* unit_ids * unit_ids
* unit_ids * unit_ids
......
...@@ -164,7 +164,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -164,7 +164,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
//调用应用服务 //调用应用服务
agentApplicationInfoService.callAgentApplication(agentId, infoEntity.getLargeModel(), infoEntity.getUnitIds() agentApplicationInfoService.callAgentApplication(agentId, infoEntity.getLargeModel(), infoEntity.getUnitIds()
, infoEntity.getAgentSystem(), kdIds.toArray(new Integer[0]), infoEntity.getCommunicationTurn(), infoEntity.getTopP() , infoEntity.getAgentSystem(), kdIds.toArray(new Integer[0]), infoEntity.getCommunicationTurn(), infoEntity.getTopP(), infoEntity.getTemperature()
, dto.getMessages(), tools, httpServletResponse); , dto.getMessages(), tools, httpServletResponse);
} catch (Exception e) { } catch (Exception e) {
httpServletResponse.setContentType("text/event-stream"); httpServletResponse.setContentType("text/event-stream");
......
...@@ -189,6 +189,10 @@ public class BizAgentApplicationInfoServiceImpl extends BaseServiceImpl ...@@ -189,6 +189,10 @@ public class BizAgentApplicationInfoServiceImpl extends BaseServiceImpl
if (entity.getTopP() != null) { if (entity.getTopP() != null) {
Assert.isTrue(entity.getTopP() >= 0 && entity.getTopP() <= 1.00, "top p is error,must more than 0 and less than 1.0"); Assert.isTrue(entity.getTopP() >= 0 && entity.getTopP() <= 1.00, "top p is error,must more than 0 and less than 1.0");
} }
if (entity.getTemperature() != null) {
Assert.isTrue(entity.getTemperature() > 0 && entity.getTemperature() <= 1.0, "temperature is error,must greater than 0, less than or equal to 1.9");
}
model.setTemperature(entity.getTemperature());
model.setTopP(entity.getTopP()); model.setTopP(entity.getTopP());
model.setContinuousQuestionStatus(entity.getContinuousQuestionStatus()); model.setContinuousQuestionStatus(entity.getContinuousQuestionStatus());
model.setContinuousQuestionSystem(entity.getContinuousQuestionSystem()); model.setContinuousQuestionSystem(entity.getContinuousQuestionSystem());
......
...@@ -40,7 +40,6 @@ import java.util.HashSet; ...@@ -40,7 +40,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
@Service @Service
public class AgentApplicationServiceImpl implements AgentApplicationService { public class AgentApplicationServiceImpl implements AgentApplicationService {
...@@ -114,7 +113,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService { ...@@ -114,7 +113,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
String output = agentApplicationInfoService.callAgentApplication(dialogsId, infoEntity.getLargeModel(), String output = agentApplicationInfoService.callAgentApplication(dialogsId, infoEntity.getLargeModel(),
infoEntity.getUnitIds(), infoEntity.getAgentSystem(), kdIdList.toArray(new Integer[0]), infoEntity.getCommunicationTurn(), infoEntity.getUnitIds(), infoEntity.getAgentSystem(), kdIdList.toArray(new Integer[0]), infoEntity.getCommunicationTurn(),
infoEntity.getTopP(), messages, tools, httpServletResponse); infoEntity.getTopP(), infoEntity.getTemperature(), messages, tools, httpServletResponse);
//保存对话记录 //保存对话记录
......
...@@ -2,6 +2,8 @@ package cn.com.poc; ...@@ -2,6 +2,8 @@ package cn.com.poc;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService; import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.common.service.RedisService;
import cn.com.poc.expose.aggregate.AgentApplicationService;
import cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService; import cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService;
import cn.com.yict.framemax.core.spring.SingleContextInitializer; import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -30,6 +32,9 @@ public class AgentApplicationInfoTest { ...@@ -30,6 +32,9 @@ public class AgentApplicationInfoTest {
@Resource @Resource
private DemandKnowledgeService demandKnowledgeService; private DemandKnowledgeService demandKnowledgeService;
@Resource
private RedisService redisService;
/** /**
* Agent 应用标题,描述生成 * Agent 应用标题,描述生成
*/ */
...@@ -46,4 +51,19 @@ public class AgentApplicationInfoTest { ...@@ -46,4 +51,19 @@ public class AgentApplicationInfoTest {
System.out.println(list.toString()); System.out.println(list.toString());
} }
@Test
public void test() {
List<Object> list = Lists.newArrayList("1", "2", "3", "4", "5", "6", "7", "8", "9", "1");
redisService.lSet("key",list);
}
@Resource
private AgentApplicationService agentApplicationService;
@Test
public void test2() throws InterruptedException {
agentApplicationService.createRecommendQuestion();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment