Commit cd8ecc0b authored by alex yao's avatar alex yao

feat: 搜索模型信息

parent 84d0d5e2
...@@ -4,12 +4,10 @@ import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService; ...@@ -4,12 +4,10 @@ import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.agent_application.constant.AgentApplicationConstants; import cn.com.poc.agent_application.constant.AgentApplicationConstants;
import cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants; import cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants;
import cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants; import cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants;
import cn.com.poc.agent_application.entity.BizAgentApplicationGcConfigEntity; import cn.com.poc.agent_application.entity.*;
import cn.com.poc.agent_application.entity.BizAgentApplicationInfoEntity;
import cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity;
import cn.com.poc.agent_application.entity.CreateAgentTitleAndDescEntity;
import cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService; import cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService;
import cn.com.poc.agent_application.service.BizAgentApplicationInfoService; import cn.com.poc.agent_application.service.BizAgentApplicationInfoService;
import cn.com.poc.agent_application.service.BizAgentApplicationLargeModelListService;
import cn.com.poc.agent_application.service.BizAgentApplicationPublishService; import cn.com.poc.agent_application.service.BizAgentApplicationPublishService;
import cn.com.poc.common.utils.BlContext; import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.JsonUtils; import cn.com.poc.common.utils.JsonUtils;
...@@ -32,7 +30,6 @@ import org.apache.commons.lang3.StringUtils; ...@@ -32,7 +30,6 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -54,6 +51,9 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -54,6 +51,9 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
final private Logger logger = LoggerFactory.getLogger(AgentApplicationInfoService.class); final private Logger logger = LoggerFactory.getLogger(AgentApplicationInfoService.class);
@Resource
private BizAgentApplicationLargeModelListService bizAgentApplicationLargeModelListService;
@Resource @Resource
private BizAgentApplicationGcConfigService bizAgentApplicationGcConfigService; private BizAgentApplicationGcConfigService bizAgentApplicationGcConfigService;
...@@ -95,13 +95,19 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -95,13 +95,19 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
@Override @Override
public String callAgentApplication(String largeModel, String[] unitIds, String agentSystem, String[] knowledgeIds, Integer communicationTurn, Float topP, List<Message> messages, HttpServletResponse httpServletResponse) throws Exception { public String callAgentApplication(String largeModel, String[] unitIds, String agentSystem, String[] knowledgeIds, Integer communicationTurn, Float topP, List<Message> messages, HttpServletResponse httpServletResponse) throws Exception {
logger.info("--------- Call Agent Application large model:{},unitIds:{},agentSystem:{},knowledgeIds:{}" + " communicationTurn:{},topP:{},messages:{}--------------", largeModel, unitIds, agentSystem, knowledgeIds, communicationTurn, topP, messages); logger.info("--------- Call Agent Application large model:{},unitIds:{},agentSystem:{},knowledgeIds:{}" + " communicationTurn:{},topP:{},messages:{}--------------", largeModel, unitIds, agentSystem, knowledgeIds, communicationTurn, topP, messages);
BizAgentApplicationLargeModelListEntity largeModelEntity = bizAgentApplicationLargeModelListService.findByModelNickName(largeModel);
if (largeModelEntity == null) {
throw new BusinessException("模型不存在");
}
//todo 调用组件 //todo 调用组件
String promptTemplate = buildDialogsPrompt(messages, agentSystem, knowledgeIds); String promptTemplate = buildDialogsPrompt(messages, agentSystem, knowledgeIds);
Message[] messageArray = buildMessages(messages, communicationTurn, promptTemplate); Message[] messageArray = buildMessages(messages, communicationTurn, promptTemplate);
BufferedReader bufferedReader = invokeLLM(largeModel, messageArray, topP); BufferedReader bufferedReader = invokeLLM(largeModelEntity.getModelName(), messageArray, topP);
return textOutput(httpServletResponse, bufferedReader); return textOutput(httpServletResponse, bufferedReader);
} }
......
package cn.com.poc.agent_application.service; package cn.com.poc.agent_application.service;
import cn.com.yict.framemax.core.service.BaseService;
import cn.com.poc.agent_application.entity.BizAgentApplicationLargeModelListEntity; import cn.com.poc.agent_application.entity.BizAgentApplicationLargeModelListEntity;
import cn.com.yict.framemax.core.service.BaseService;
import cn.com.yict.framemax.data.model.PagingInfo; import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.Collection;
import java.util.List; import java.util.List;
public interface BizAgentApplicationLargeModelListService extends BaseService { public interface BizAgentApplicationLargeModelListService extends BaseService {
BizAgentApplicationLargeModelListEntity findByModelNickName(String modelNickName);
BizAgentApplicationLargeModelListEntity get(java.lang.Integer id) throws Exception; BizAgentApplicationLargeModelListEntity get(java.lang.Integer id) throws Exception;
List<BizAgentApplicationLargeModelListEntity> findByExample(BizAgentApplicationLargeModelListEntity example,PagingInfo pagingInfo) throws Exception; List<BizAgentApplicationLargeModelListEntity> findByExample(BizAgentApplicationLargeModelListEntity example,PagingInfo pagingInfo) throws Exception;
......
package cn.com.poc.agent_application.service.impl; package cn.com.poc.agent_application.service.impl;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl; import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.agent_application.service.BizAgentApplicationLargeModelListService; import cn.com.poc.agent_application.service.BizAgentApplicationLargeModelListService;
...@@ -10,70 +10,85 @@ import cn.com.yict.framemax.data.model.PagingInfo; ...@@ -10,70 +10,85 @@ import cn.com.yict.framemax.data.model.PagingInfo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@Service @Service
public class BizAgentApplicationLargeModelListServiceImpl extends BaseServiceImpl public class BizAgentApplicationLargeModelListServiceImpl extends BaseServiceImpl
implements BizAgentApplicationLargeModelListService { implements BizAgentApplicationLargeModelListService {
@Resource @Resource
private BizAgentApplicationLargeModelListRepository repository; private BizAgentApplicationLargeModelListRepository repository;
public BizAgentApplicationLargeModelListEntity get(java.lang.Integer id) throws Exception{ @Override
public BizAgentApplicationLargeModelListEntity findByModelNickName(String modelNickName) {
Assert.notNull(modelNickName);
BizAgentApplicationLargeModelListModel bizAgentApplicationLargeModelListModel = new BizAgentApplicationLargeModelListModel();
bizAgentApplicationLargeModelListModel.setModelNickName(modelNickName);
List<BizAgentApplicationLargeModelListModel> models = this.repository.findByExample(bizAgentApplicationLargeModelListModel);
if (CollectionUtils.isNotEmpty(models)) {
return BizAgentApplicationLargeModelListConvert.modelToEntity(models.get(0));
}
return null;
}
public BizAgentApplicationLargeModelListEntity get(java.lang.Integer id) throws Exception {
Assert.notNull(id); Assert.notNull(id);
BizAgentApplicationLargeModelListModel model = this.repository.get(id); BizAgentApplicationLargeModelListModel model = this.repository.get(id);
if (model == null){ if (model == null) {
return null; return null;
} }
return BizAgentApplicationLargeModelListConvert.modelToEntity(model); return BizAgentApplicationLargeModelListConvert.modelToEntity(model);
} }
public List<BizAgentApplicationLargeModelListEntity> findByExample(BizAgentApplicationLargeModelListEntity example,PagingInfo pagingInfo) throws Exception{ public List<BizAgentApplicationLargeModelListEntity> findByExample(BizAgentApplicationLargeModelListEntity example, PagingInfo pagingInfo) throws Exception {
List<BizAgentApplicationLargeModelListEntity> result = new ArrayList<BizAgentApplicationLargeModelListEntity>(); List<BizAgentApplicationLargeModelListEntity> result = new ArrayList<BizAgentApplicationLargeModelListEntity>();
BizAgentApplicationLargeModelListModel model = new BizAgentApplicationLargeModelListModel(); BizAgentApplicationLargeModelListModel model = new BizAgentApplicationLargeModelListModel();
if (example != null){ if (example != null) {
model = BizAgentApplicationLargeModelListConvert.entityToModel(example); model = BizAgentApplicationLargeModelListConvert.entityToModel(example);
} }
List<BizAgentApplicationLargeModelListModel> models = this.repository.findByExample(model,pagingInfo); List<BizAgentApplicationLargeModelListModel> models = this.repository.findByExample(model, pagingInfo);
if (CollectionUtils.isNotEmpty(models)) { if (CollectionUtils.isNotEmpty(models)) {
result = models.stream().map(BizAgentApplicationLargeModelListConvert::modelToEntity).collect(Collectors.toList()); result = models.stream().map(BizAgentApplicationLargeModelListConvert::modelToEntity).collect(Collectors.toList());
} }
return result; return result;
} }
public BizAgentApplicationLargeModelListEntity save(BizAgentApplicationLargeModelListEntity entity) throws Exception{ public BizAgentApplicationLargeModelListEntity save(BizAgentApplicationLargeModelListEntity entity) throws Exception {
Assert.notNull(entity); Assert.notNull(entity);
entity.setId(null); entity.setId(null);
BizAgentApplicationLargeModelListModel model = BizAgentApplicationLargeModelListConvert.entityToModel(entity); BizAgentApplicationLargeModelListModel model = BizAgentApplicationLargeModelListConvert.entityToModel(entity);
BizAgentApplicationLargeModelListModel saveModel = this.repository.save(model); BizAgentApplicationLargeModelListModel saveModel = this.repository.save(model);
return BizAgentApplicationLargeModelListConvert.modelToEntity(saveModel); return BizAgentApplicationLargeModelListConvert.modelToEntity(saveModel);
} }
public BizAgentApplicationLargeModelListEntity update(BizAgentApplicationLargeModelListEntity entity) throws Exception{ public BizAgentApplicationLargeModelListEntity update(BizAgentApplicationLargeModelListEntity entity) throws Exception {
Assert.notNull(entity); Assert.notNull(entity);
Assert.notNull(entity.getId(),"update pk can not be null"); Assert.notNull(entity.getId(), "update pk can not be null");
BizAgentApplicationLargeModelListModel model = this.repository.get(entity.getId()); BizAgentApplicationLargeModelListModel model = this.repository.get(entity.getId());
if (entity.getModelName() != null){ if (entity.getModelName() != null) {
model.setModelName(entity.getModelName()); model.setModelName(entity.getModelName());
} }
if (entity.getOwner() != null){ if (entity.getOwner() != null) {
model.setOwner(entity.getOwner()); model.setOwner(entity.getOwner());
} }
BizAgentApplicationLargeModelListModel saveModel = this.repository.save(model); BizAgentApplicationLargeModelListModel saveModel = this.repository.save(model);
return BizAgentApplicationLargeModelListConvert.modelToEntity(saveModel); return BizAgentApplicationLargeModelListConvert.modelToEntity(saveModel);
} }
public void deletedById(java.lang.Integer id) throws Exception{ public void deletedById(java.lang.Integer id) throws Exception {
Assert.notNull(id); Assert.notNull(id);
BizAgentApplicationLargeModelListModel model = this.repository.get(id); BizAgentApplicationLargeModelListModel model = this.repository.get(id);
if (model != null){ if (model != null) {
} }
} }
} }
\ No newline at end of file
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