Commit cbfef1d5 authored by alex yao's avatar alex yao

Merge branch 'release' into task/1004390

# Conflicts:
#	src/main/java/cn/com/poc/agent_application/aggregate/impl/AgentApplicationInfoServiceImpl.java
#	src/main/java/cn/com/poc/agent_application/entity/BizAgentApplicationPublishEntity.java
parents a3dcd50a 05a09c72
......@@ -107,12 +107,6 @@
<version>8.0.28</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- ES -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
......@@ -245,11 +239,14 @@
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
......@@ -260,6 +257,13 @@
<artifactId>ooxml-schemas</artifactId>
<version>1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
......@@ -277,11 +281,6 @@
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-http -->
<dependency>
......
......@@ -19,7 +19,7 @@ public interface AgentApplicationInfoService {
* 应用预览
*/
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;
/**
......
......@@ -103,7 +103,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
@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);
String model = modelConvert(largeModel);
......@@ -324,6 +324,13 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
return JsonUtils.deSerialize(res.substring(start, end + 1), CreateAgentTitleAndDescEntity.class);
}
@Override
public boolean unPublish(String agentId) throws Exception {
bizAgentApplicationPublishService.deleteByAgentId(agentId);
bizAgentApplicationInfoService.unPublish(agentId);
return true;
}
/**
* 构建应用信息提示词
*
......@@ -373,7 +380,14 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
knowledgeIds.add(knowledgeDocumentEntity.getKnowledgeId());
}
List<String> knowledgeResults = demandKnowledgeService.searchKnowledge(messages.get(messages.size() - 1).getContent().get(0).getText(), knowledgeIds, 3);
Object content = messages.get(messages.size() - 1).getContent();
String query = "";
if (content instanceof List) {
query = ((List<MultiContent>) content).get(0).getText();
} else {
query = content.toString();
}
List<String> knowledgeResults = demandKnowledgeService.searchKnowledge(query, knowledgeIds, 3);
promptTemplate = promptTemplate.replace("${knowledgeResults}", knowledgeResults.toString());
}
// 记忆
......@@ -585,7 +599,7 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
* @param promptTemplate
* @return
*/
private static Message[] buildMessages(List<Message> messages, Integer communicationTurn, String promptTemplate) {
private Message[] buildMessages(List<Message> messages, Integer communicationTurn, String promptTemplate) {
int messLength = messages.size() - 1;
int skip = communicationTurn * 2;
if (skip < messLength) {
......@@ -593,17 +607,24 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
}
if (StringUtils.isNotBlank(promptTemplate)) {
List<MultiContent> content = new ArrayList<>();
MultiContent multiContent = new MultiContent();
multiContent.setText(promptTemplate);
multiContent.setType("text");
content.add(multiContent);
Message systemMessage = new Message();
systemMessage.setRole(AgentApplicationDialoguesRecordConstants.ROLE.SYSTEM);
systemMessage.setContent(content);
systemMessage.setContent(promptTemplate);
messages.add(0, systemMessage);
}
return messages.toArray(new Message[0]);
// 转换消息体
Message[] messageArray = new Message[messages.size()];
int index = 0;
for (Message message : messages) {
if (message.getContent() instanceof List) {
List<HashMap<String,Object>> content = (List<HashMap<String,Object>>) message.getContent();
if (content.get(0).get("type").equals("text")) {
message.setContent(content.get(0).get("text").toString());
}
}
messageArray[index++] = message;
}
return messageArray;
}
......
......@@ -58,6 +58,7 @@ public class AgentApplicationInfoConvert {
}
entity.setLargeModel(model.getLargeModel());
entity.setTopP(model.getTopP());
entity.setTemperature(model.getTemperature());
if (StringUtils.isNotBlank(model.getUnitIds())) {
entity.setUnitIds(JsonUtils.deSerialize(model.getUnitIds(), String[].class));
}
......@@ -98,6 +99,7 @@ public class AgentApplicationInfoConvert {
}
model.setLargeModel(entity.getLargeModel());
model.setTopP(entity.getTopP());
model.setTemperature(entity.getTemperature());
if (ArrayUtils.isNotEmpty(entity.getUnitIds())) {
model.setUnitIds(JsonUtil.toJson(entity.getUnitIds()));
}
......@@ -137,6 +139,7 @@ public class AgentApplicationInfoConvert {
AgentApplicationCommModelConfig commModelConfig = new AgentApplicationCommModelConfig();
commModelConfig.setLargeModel(entity.getLargeModel());
commModelConfig.setTopP(entity.getTopP());
commModelConfig.setTemperature(entity.getTemperature());
commModelConfig.setCommunicationTurn(entity.getCommunicationTurn());
AgentApplicationInfoDto dto = new AgentApplicationInfoDto();
......@@ -184,6 +187,7 @@ public class AgentApplicationInfoConvert {
if (ObjectUtil.isNotEmpty(dto.getCommModelConfig())) {
entity.setLargeModel(dto.getCommModelConfig().getLargeModel());
entity.setTopP(dto.getCommModelConfig().getTopP());
entity.setTemperature(dto.getCommModelConfig().getTemperature());
entity.setCommunicationTurn(dto.getCommModelConfig().getCommunicationTurn());
}
......@@ -225,6 +229,7 @@ public class AgentApplicationInfoConvert {
}
entity.setLargeModel(infoQueryItem.getLargeModel());
entity.setTopP(infoQueryItem.getTopP());
entity.setTemperature(infoQueryItem.getTemperature());
if (StringUtils.isNotBlank(infoQueryItem.getUnitIds())) {
entity.setUnitIds(JsonUtils.deSerialize(infoQueryItem.getUnitIds(), String[].class));
}
......
......@@ -46,6 +46,7 @@ public class BizAgentApplicationPublishConvert {
}
entity.setLargeModel(model.getLargeModel());
entity.setTopP(model.getTopP());
entity.setTemperature(model.getTemperature());
if (StringUtils.isNotBlank(model.getUnitIds())) {
entity.setUnitIds(JsonUtils.deSerialize(model.getUnitIds(), String[].class));
}
......@@ -84,6 +85,7 @@ public class BizAgentApplicationPublishConvert {
}
model.setLargeModel(entity.getLargeModel());
model.setTopP(entity.getTopP());
model.setTemperature(entity.getTemperature());
if (ArrayUtils.isNotEmpty(entity.getUnitIds())) {
model.setUnitIds(JsonUtil.toJson(entity.getUnitIds()));
}
......@@ -123,6 +125,7 @@ public class BizAgentApplicationPublishConvert {
AgentApplicationCommModelConfig commModelConfig = new AgentApplicationCommModelConfig();
commModelConfig.setLargeModel(entity.getLargeModel());
commModelConfig.setTopP(entity.getTopP());
commModelConfig.setTemperature(entity.getTemperature());
commModelConfig.setCommunicationTurn(entity.getCommunicationTurn());
dto.setBaseInfo(baseInfo);
......@@ -170,6 +173,7 @@ public class BizAgentApplicationPublishConvert {
if (ObjectUtil.isNotEmpty(dto.getCommModelConfig())) {
entity.setLargeModel(dto.getCommModelConfig().getLargeModel());
entity.setTopP(dto.getCommModelConfig().getTopP());
entity.setTemperature(dto.getCommModelConfig().getTemperature());
}
entity.setUnitIds(dto.getUnitIds());
......
......@@ -33,6 +33,20 @@ public class AgentApplicationCommModelConfig {
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
* 对话上下文保存轮次
......
......@@ -7,11 +7,50 @@ import java.util.List;
public class AgentApplicationPreviewDto implements Serializable {
private String modelNickName;
private Float topP;
private Float temperature;
private String agentSystem;
private String agentId;
private List<Message> messages;
public Float getTopP() {
return topP;
}
public void setTopP(Float topP) {
this.topP = topP;
}
public Float getTemperature() {
return temperature;
}
public void setTemperature(Float temperature) {
this.temperature = temperature;
}
public String getAgentSystem() {
return agentSystem;
}
public void setAgentSystem(String agentSystem) {
this.agentSystem = agentSystem;
}
public String getModelNickName() {
return modelNickName;
}
public void setModelNickName(String modelNickName) {
this.modelNickName = modelNickName;
}
public String getAgentId() {
return agentId;
}
......
package cn.com.poc.agent_application.entity;
import java.util.Arrays;
public class BizAgentApplicationPublishEntity {
private static final long serialVersionUID = 1L;
......@@ -236,6 +234,22 @@ public class BizAgentApplicationPublishEntity {
public void setTopP(java.lang.Float 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
*组件ID
*/
......@@ -336,37 +350,4 @@ public class BizAgentApplicationPublishEntity {
public void setSysVersion(java.lang.Integer sysVersion){
this.sysVersion = sysVersion;
}
@Override
public String toString() {
return "BizAgentApplicationPublishEntity{" +
"id=" + id +
", memberId=" + memberId +
", agentId='" + agentId + '\'' +
", agentAvatar='" + agentAvatar + '\'' +
", agentTitle='" + agentTitle + '\'' +
", agentDesc='" + agentDesc + '\'' +
", agentSystem='" + agentSystem + '\'' +
", agentPublishStatus='" + agentPublishStatus + '\'' +
", publishTime=" + publishTime +
", preamble='" + preamble + '\'' +
", variableStructure=" + Arrays.toString(variableStructure) +
", featuredQuestions=" + Arrays.toString(featuredQuestions) +
", communicationTurn=" + communicationTurn +
", continuousQuestionStatus='" + continuousQuestionStatus + '\'' +
", continuousQuestionSystem='" + continuousQuestionSystem + '\'' +
", continuousQuestionTurn=" + continuousQuestionTurn +
", knowledgeIds=" + Arrays.toString(knowledgeIds) +
", largeModel='" + largeModel + '\'' +
", topP=" + topP +
", unitIds=" + Arrays.toString(unitIds) +
", isLongMemory='" + isLongMemory + '\'' +
", isDeleted='" + isDeleted + '\'' +
", creator='" + creator + '\'' +
", createdTime=" + createdTime +
", modifier='" + modifier + '\'' +
", modifiedTime=" + modifiedTime +
", sysVersion=" + sysVersion +
'}';
}
}
\ No newline at end of file
......@@ -314,6 +314,25 @@ public class BizAgentApplicationInfoModel extends BaseModelClass implements Seri
}
/** 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
*组件ID
*/
......
......@@ -297,6 +297,23 @@ public class BizAgentApplicationPublishModel extends BaseModelClass implements S
}
/** 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
*组件ID
*/
......
......@@ -17,6 +17,7 @@ select distinct
knowledge_ids,
large_model,
top_p,
temperature,
unit_ids,
variable_structure,
is_long_memory,
......
......@@ -284,6 +284,23 @@ public class AgentApplicationInfoQueryItem extends BaseItemClass implements Seri
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
......
......@@ -187,22 +187,28 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
List<Tool> tools = new ArrayList<>();
//开启对话变量
if (ArrayUtils.isNotEmpty(infoEntity.getVariableStructure())) {
String functionName = "set_value_memory";
String functionName = LargeModelFunctionEnum.set_value_memory.name();
String llmConfig = LargeModelFunctionEnum.valueOf(functionName).getFunction().getVariableStructureLLMConfig(infoEntity.getVariableStructure()).get(0);
Tool tool = JsonUtils.deSerialize(llmConfig, Tool.class);
tools.add(tool);
}
//开启长期记忆
if (CommonConstant.YOrN.Y.equals(infoEntity.getIsLongMemory())) {
String functionName = "set_long_memory";
String functionName = LargeModelFunctionEnum.set_long_memory.name();
String llmConfig = LargeModelFunctionEnum.valueOf(functionName).getFunction().getLLMConfig().get(0);
Tool tool = JsonUtils.deSerialize(llmConfig, Tool.class);
tools.add(tool);
}
//对话大模型配置
String model = StringUtils.isNotBlank(dto.getModelNickName()) ? dto.getModelNickName() : infoEntity.getLargeModel();
Float topP = dto.getTopP() == null ? infoEntity.getTopP() : dto.getTopP();
Float temperature = dto.getTemperature() == null ? infoEntity.getTemperature() : dto.getTemperature();
String agentSystem = StringUtils.isBlank(dto.getAgentSystem()) ? infoEntity.getAgentSystem() : dto.getAgentSystem();
//调用应用服务
agentApplicationInfoService.callAgentApplication(agentId, infoEntity.getLargeModel(), infoEntity.getUnitIds()
, infoEntity.getAgentSystem(), kdIds.toArray(new Integer[0]), infoEntity.getCommunicationTurn(), infoEntity.getTopP()
agentApplicationInfoService.callAgentApplication(agentId, model, infoEntity.getUnitIds()
, agentSystem, kdIds.toArray(new Integer[0]), infoEntity.getCommunicationTurn(), topP, temperature
, dto.getMessages(), tools, httpServletResponse);
} catch (Exception e) {
httpServletResponse.setContentType("text/event-stream");
......
package cn.com.poc.agent_application.scheduler;
import cn.com.poc.expose.aggregate.AgentApplicationService;
import cn.com.poc.knowledge.constant.KnowledgeConstant;
import cn.com.poc.knowledge.query.KnowledgeInfosQueryCondition;
import cn.com.poc.knowledge.query.KnowledgeInfosQueryItem;
import cn.com.poc.message.entity.KnowledgeTrainStatusMessage;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
@Component
public class RecommendQuestionScheduler {
@Resource
private AgentApplicationService agentApplicationService;
/**
* 每日凌晨
*
* @throws Exception
*/
@Scheduled(cron = "0 0 0 * * ?")
public void knowledgeInfoStatusUpdateScheduler() throws Exception {
agentApplicationService.createRecommendQuestion();
}
}
......@@ -173,6 +173,10 @@ public class BizAgentApplicationInfoServiceImpl extends BaseServiceImpl
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");
}
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.setContinuousQuestionStatus(entity.getContinuousQuestionStatus());
model.setContinuousQuestionSystem(entity.getContinuousQuestionSystem());
......
......@@ -8,15 +8,15 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
/**
* Communication 线程池
* 公共业务线程池
*/
public class CommunicationThreadPoolExecutor {
public class CommonThreadPoolExecutor {
final private static String THREAD_POOL_NAME = "CommunicationThreadExecutor";
final private static String THREAD_POOL_NAME = "Common_Thread_Executor";
final private static int CORE_POOL_SIZE = Runtime.getRuntime().availableProcessors();
final private static int MAXIMUM_POOL_SIZE = Runtime.getRuntime().availableProcessors() * 5;
final private static int MAXIMUM_POOL_SIZE = Runtime.getRuntime().availableProcessors() * 20;
final private static int KEEP_ALIVE_TIME = 60;
......
......@@ -6,7 +6,7 @@ import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream;
import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
//import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.util.Assert;
......@@ -31,7 +31,7 @@ public class DocumentLoad {
case "docx":
return loadWordDocx(file);
case "doc":
return loadWordDocx(file);
return loadWordDoc(file);
case "md":
return loadMarkDown(file);
case "pdf":
......@@ -62,12 +62,12 @@ public class DocumentLoad {
return xwpfWordExtractor.getText();
}
// public static String loadWordDoc(File file) throws IOException {
// FileInputStream fis = new FileInputStream(file);
// HWPFDocument doc = new HWPFDocument(fis);
// fis.close();
// return doc.getText().toString();
// }
public static String loadWordDoc(File file) throws IOException {
FileInputStream fis = new FileInputStream(file);
WordExtractor wordExtractor = new WordExtractor(fis);
fis.close();
return wordExtractor.getText().toString();
}
public static String loadTxt(File file) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
......
......@@ -18,4 +18,16 @@ public interface AgentApplicationService {
*/
List<String> createContinueQuestions(String input);
/**
* [首页] 获取推荐问
*/
List<String> getRecommendQuestions() throws InterruptedException;
/**
* [首页] 生成推荐问
*
* @throws InterruptedException
*/
void createRecommendQuestion() throws InterruptedException;
}
package cn.com.poc.expose.rest;
import cn.com.poc.agent_application.dto.AgentApplicationCreateContinueQuesDto;
import cn.com.poc.agent_application.dto.AgentApplicationInfoDto;
import cn.com.poc.agent_application.dto.AgentApplicationInfoSearchDto;
import cn.com.poc.agent_application.dto.BizAgentApplicationPublishDto;
import cn.com.poc.expose.dto.AgentApplicationDto;
......@@ -21,10 +20,15 @@ import java.util.List;
@Permission(value = Access.Safety)
public interface AgentApplicationRest extends BaseRest {
/**
* 【首页】 获取推荐问
*/
List<String> getRecommendQuestions() throws Exception;
/**
* 创建对话
*/
String createDialogues(@RequestParam String agentId) throws Exception;
String createDialogues() throws Exception;
/**
* 调用 已发布Agent应用
......@@ -43,6 +47,12 @@ public interface AgentApplicationRest extends BaseRest {
@Permission(value = Access.Anonymous)
BizAgentApplicationPublishDto getInfo(@RequestParam String agentId) throws Exception;
/**
* 获取 已发布[官方]默认应用列表
*/
@Permission(value = Access.Anonymous)
List<SearchAgentApplicationDto> getDefaultList(PagingInfo pagingInfo) throws Exception;
/**
* 下架已发布应用
*/
......
......@@ -2,11 +2,9 @@ package cn.com.poc.expose.rest.impl;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.agent_application.convert.AgentApplicationInfoConvert;
import cn.com.poc.agent_application.convert.BizAgentApplicationDialoguesRecordConvert;
import cn.com.poc.agent_application.convert.BizAgentApplicationPublishConvert;
import cn.com.poc.agent_application.dto.AgentApplicationCreateContinueQuesDto;
import cn.com.poc.agent_application.dto.AgentApplicationInfoSearchDto;
import cn.com.poc.agent_application.dto.BizAgentApplicationDialoguesRecordDto;
import cn.com.poc.agent_application.dto.BizAgentApplicationPublishDto;
import cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity;
import cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity;
......@@ -57,7 +55,12 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
private BizAgentApplicationDialoguesRecordService bizAgentApplicationDialoguesRecordService;
@Override
public String createDialogues(String agentId) {
public List<String> getRecommendQuestions() throws Exception {
return agentApplicationService.getRecommendQuestions();
}
@Override
public String createDialogues() {
return "DIA_" + UUIDTool.getUUID();
}
......@@ -102,6 +105,28 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
return BizAgentApplicationPublishConvert.entityToDto(entity);
}
@Override
public List<SearchAgentApplicationDto> getDefaultList(PagingInfo pagingInfo) throws Exception {
List<SearchAgentApplicationDto> result = new ArrayList<>();
BizAgentApplicationPublishEntity publishEntity = new BizAgentApplicationPublishEntity();
publishEntity.setMemberId(0);
publishEntity.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizAgentApplicationPublishEntity> entities = bizAgentApplicationPublishService.findByExample(publishEntity, pagingInfo);
if (CollectionUtils.isNotEmpty(entities)) {
result = entities.stream().map(value -> {
SearchAgentApplicationDto searchAgentApplicationDto = new SearchAgentApplicationDto();
searchAgentApplicationDto.setAgentId(value.getAgentId());
searchAgentApplicationDto.setAgentTitle(value.getAgentTitle());
searchAgentApplicationDto.setAgentDesc(value.getAgentDesc());
searchAgentApplicationDto.setAgentAvatar(value.getAgentAvatar());
searchAgentApplicationDto.setPublishedTime(value.getModifiedTime());
searchAgentApplicationDto.setCreator("官方");
return searchAgentApplicationDto;
}).collect(Collectors.toList());
}
return result;
}
@Override
public void unPublish(String agentId) throws Exception {
Assert.notBlank(agentId, "应用ID不能为空");
......@@ -127,7 +152,8 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
result = memberDialoguesQueryItems.stream().map(item -> {
UserDialoguesDto userDialoguesDto = new UserDialoguesDto();
userDialoguesDto.setDialogsId(item.getDialogsId());
userDialoguesDto.setContent(item.getContent());
String content = item.getContent().length() > 20 ? item.getContent().substring(0, 20) : item.getContent();
userDialoguesDto.setContent(content);
return userDialoguesDto;
}).collect(Collectors.toList());
}
......
......@@ -61,7 +61,7 @@ public interface KnowledgeService {
/**
* 获取知识库分片
*/
GetKnowledgeChunkInfoResult getChunkInfo(List<Integer> kdIds, PagingInfo pagingInfo);
GetKnowledgeChunkInfoResult getChunkInfo(List<Integer> kdIds, String query, PagingInfo pagingInfo);
/**
* 开关知识库分片
......
......@@ -81,7 +81,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
long fileSizeInBytes = file.length();
double fileSizeInMB = (double) fileSizeInBytes / (1024 * 1024);
if (fileSizeInMB > 10) {
throw new BusinessException("上传的文件不能超过5M,文件名:" + documentName);
throw new BusinessException("上传的文件不能超过10M,文件名:" + documentName);
}
String fileContent = DocumentLoad.documentToText(file).replaceAll(StringUtils.LF, StringUtils.EMPTY).replaceAll(StringUtils.CR, StringUtils.EMPTY);//文件内容
......@@ -91,8 +91,8 @@ public class KnowledgeServiceImpl implements KnowledgeService {
//获取文件字符数
long charCount = fileContent.length();
//文件字符数不能超过100w
if (charCount > 2 * 10000) {
throw new BusinessException("文件内容字符数不能超过2w,文件名: " + documentName);
if (charCount > 100 * 10000) {
throw new BusinessException("文件内容字符数不能超过100w,文件名: " + documentName);
}
//文件上传
......@@ -242,14 +242,14 @@ public class KnowledgeServiceImpl implements KnowledgeService {
}
@Override
public GetKnowledgeChunkInfoResult getChunkInfo(List<Integer> kdIds, PagingInfo pagingInfo) {
public GetKnowledgeChunkInfoResult getChunkInfo(List<Integer> kdIds, String query, PagingInfo pagingInfo) {
List<String> knowledgeIds = new ArrayList<>();
for (Integer kdId : kdIds) {
BizKnowledgeDocumentEntity bizKnowledgeDocumentEntity = bizKnowledgeDocumentService.get(kdId);
String knowledgeId = bizKnowledgeDocumentEntity.getKnowledgeId();
knowledgeIds.add(knowledgeId);
}
return demandKnowledgeService.getKnowledgeChunkInfos(knowledgeIds, pagingInfo);
return demandKnowledgeService.getKnowledgeChunkInfos(knowledgeIds, query, pagingInfo);
}
@Override
......
......@@ -52,7 +52,7 @@ public class BizKnowledgeInfoConvert {
dto.setKdIds(entity.getKdIds());
dto.setTrainStatus(entity.getTrainStatus());
dto.setDesc(entity.getKnowledgeDesc());
dto.setModifiedTime(entity.getModifiedTime());
dto.setCreatedTime(entity.getCreatedTime());
return dto;
}
......
......@@ -101,18 +101,17 @@ public class BizKnowledgeInfoDto {
}
/**
* MODIFIED_TIME
* MODIFIED_TIME
* createdTime
* createdTime
*/
private java.util.Date modifiedTime;
private java.util.Date createdTime;
@Column(name = "MODIFIED_TIME")
public java.util.Date getModifiedTime() {
return this.modifiedTime;
public java.util.Date getCreatedTime() {
return this.createdTime;
}
public void setModifiedTime(java.util.Date modifiedTime) {
this.modifiedTime = modifiedTime;
public void setCreatedTime(java.util.Date createdTime) {
this.createdTime = createdTime;
}
}
\ No newline at end of file
......@@ -142,5 +142,5 @@ public interface KnowledgeRest extends BaseRest {
/**
* 获取知识库分片信息
*/
GetKnowledgeChunkInfoResult getChunks(@RequestParam List<Integer> kdIds, PagingInfo pagingInfo);
GetKnowledgeChunkInfoResult getChunks(@RequestParam List<Integer> kdIds, @RequestParam String query, PagingInfo pagingInfo);
}
......@@ -278,8 +278,8 @@ public class KnowledgeRestImpl implements KnowledgeRest {
}
@Override
public GetKnowledgeChunkInfoResult getChunks(List<Integer> kdIds, PagingInfo pagingInfo) {
public GetKnowledgeChunkInfoResult getChunks(List<Integer> kdIds, String query, PagingInfo pagingInfo) {
Assert.notEmpty(kdIds);
return knowledgeService.getChunkInfo(kdIds, pagingInfo);
return knowledgeService.getChunkInfo(kdIds, query, pagingInfo);
}
}
package cn.com.poc.knowledge.scheduler;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.knowledge.constant.KnowledgeConstant;
import cn.com.poc.knowledge.entity.BizKnowledgeDocumentEntity;
import cn.com.poc.knowledge.query.KnowledgeInfosQueryCondition;
import cn.com.poc.knowledge.query.KnowledgeInfosQueryItem;
import cn.com.poc.knowledge.service.BizKnowledgeDocumentService;
import cn.com.poc.knowledge.service.BizKnowledgeInfoService;
import cn.com.poc.message.entity.KnowledgeTrainStatusMessage;
import cn.com.poc.message.service.KnowledgeProducerService;
import cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService;
import cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeTrainStatusConstant;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
@Component
......@@ -22,6 +29,12 @@ public class KnowledgeInfoScheduler {
@Resource
private BizKnowledgeInfoService bizKnowledgeInfoService;
@Resource
private BizKnowledgeDocumentService bizKnowledgeDocumentService;
@Resource
private DemandKnowledgeService demandKnowledgeService;
@Scheduled(cron = "0 0/1 * * * ?")
public void knowledgeInfoStatusUpdateScheduler() throws Exception {
KnowledgeInfosQueryCondition condition = new KnowledgeInfosQueryCondition();
......@@ -34,4 +47,34 @@ public class KnowledgeInfoScheduler {
knowledgeProducerService.knowledgeInfoStatusCheck(knowledgeTrainStatusMessage);
}
}
@Scheduled(cron = "0 0/1 * * * ?")
public void knowledgeDocumentStatusUpdateScheduler() throws Exception {
BizKnowledgeDocumentEntity knowledgeDocumentEntity = new BizKnowledgeDocumentEntity();
knowledgeDocumentEntity.setTrainStatus(KnowledgeConstant.TrainStatus.TRAINING);
knowledgeDocumentEntity.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizKnowledgeDocumentEntity> entities = bizKnowledgeDocumentService.findByExample(knowledgeDocumentEntity, null);
if (CollectionUtils.isEmpty(entities)) {
return;
}
for (BizKnowledgeDocumentEntity entity : entities) {
String trainKnowledgeStatus = demandKnowledgeService.trainKnowledgeStatus(entity.getKnowledgeId());
if (KnowledgeTrainStatusConstant.fail.equals(trainKnowledgeStatus)) {
KnowledgeTrainStatusMessage message = new KnowledgeTrainStatusMessage();
message.setKdId(entity.getKdId());
message.setKnowledgeId(entity.getKnowledgeId());
message.setStatus(KnowledgeConstant.TrainStatus.FAIL);
knowledgeProducerService.trainStatusUpdate(message);
//记录失败原因
} else if (KnowledgeTrainStatusConstant.success.equals(trainKnowledgeStatus)) {
KnowledgeTrainStatusMessage message = new KnowledgeTrainStatusMessage();
message.setKdId(entity.getKdId());
message.setKnowledgeId(entity.getKnowledgeId());
message.setStatus(KnowledgeConstant.TrainStatus.COMPLETE);
knowledgeProducerService.trainStatusUpdate(message);
}
}
}
}
......@@ -113,7 +113,7 @@ public class BizKnowledgeInfoServiceImpl extends BaseServiceImpl
@Override
public List<KnowledgeInfosQueryItem> knowledgeInfos(KnowledgeInfosQueryCondition condition, PagingInfo pagingInfo) throws Exception {
return this.sqlDao.query(condition, KnowledgeInfosQueryItem.class, "MODIFIED_TIME DESC",pagingInfo);
return this.sqlDao.query(condition, KnowledgeInfosQueryItem.class, "CREATED_TIME DESC",pagingInfo);
}
@Override
......
......@@ -17,6 +17,7 @@ import cn.com.poc.message.service.KnowledgeConsumerService;
import cn.com.poc.message.service.KnowledgeProducerService;
import cn.com.poc.message.topic.KnowledgeTopic;
import cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService;
import cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeTrainStatusConstant;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.tumbleweed.client.annotation.Consumer;
import com.alibaba.fastjson.TypeReference;
......@@ -50,66 +51,17 @@ public class KnowledgeConsumerServiceImpl implements KnowledgeConsumerService {
private BizKnowledgeInfoService bizKnowledgeInfoService;
/**
* 训练知识库
*
* @param message
* @return
*/
@Override
@Consumer(topic = KnowledgeTopic.TRAIN_KNOWLEDGE, scale = 3, retry = true)
public void trainKnowledge(TrainKnowledgeMessage message) throws Exception {
//修改训练状态
String knowledgeId = demandKnowledgeService.trainKnowledgeEvent(message.getFileUrl(), message.getSegmentationConfig());
KnowledgeTrainStatusMessage trainStatusMessage = new KnowledgeTrainStatusMessage();
trainStatusMessage.setStatus(KnowledgeConstant.TrainStatus.TRAINING);
trainStatusMessage.setKdId(message.getKid());
trainStatusMessage.setKnowledgeInfoId(message.getKnowledgeInfoId());
trainStatusMessage.setKnowledgeId(knowledgeId);
knowledgeProducerService.trainStatusUpdate(trainStatusMessage);
try {
String knowledgeId = demandKnowledgeService.trainKnowledge(message.getFileUrl(), message.getSegmentationConfig());
//训练日志
BizKnowledgeTrainLogEntity bizKnowledgeTrainLogEntity = new BizKnowledgeTrainLogEntity();
bizKnowledgeTrainLogEntity.setKdId(message.getKid());
bizKnowledgeTrainLogEntity.setTimestamp(System.currentTimeMillis());
bizKnowledgeTrainLogEntity.setTrainStatus(KnowledgeConstant.TrainStatus.COMPLETE);
bizKnowledgeTrainLogEntity.setFailureLog("");
bizKnowledgeTrainLogEntity.setIsDeleted(CommonConstant.IsDeleted.N);
bizKnowledgeTrainLogService.save(bizKnowledgeTrainLogEntity);
//训练完成
KnowledgeTrainStatusMessage completeMessage = new KnowledgeTrainStatusMessage();
completeMessage.setStatus(KnowledgeConstant.TrainStatus.COMPLETE);
completeMessage.setKdId(message.getKid());
completeMessage.setKnowledgeId(knowledgeId);
completeMessage.setKnowledgeInfoId(message.getKnowledgeInfoId());
knowledgeProducerService.trainStatusUpdate(completeMessage);
} catch (BusinessException e) {
logger.warn("--------------message:{},知识库训练失败:{}------------", message, e.getMessage());
//记录状态 训练失败
trainStatusMessage.setStatus(KnowledgeConstant.TrainStatus.FAIL);
trainStatusMessage.setKdId(message.getKid());
knowledgeProducerService.trainStatusUpdate(trainStatusMessage);
logger.warn("-------保存知识库训练失败状态----------");
//训练日志
BizKnowledgeTrainLogEntity bizKnowledgeTrainLogEntity = new BizKnowledgeTrainLogEntity();
bizKnowledgeTrainLogEntity.setKdId(message.getKid());
bizKnowledgeTrainLogEntity.setTimestamp(System.currentTimeMillis());
bizKnowledgeTrainLogEntity.setTrainStatus(KnowledgeConstant.TrainStatus.FAIL);
bizKnowledgeTrainLogEntity.setFailureLog(e.getMessage());
bizKnowledgeTrainLogEntity.setIsDeleted(CommonConstant.IsDeleted.N);
bizKnowledgeTrainLogService.save(bizKnowledgeTrainLogEntity);
logger.warn("-------保存知识库训练失败日志----------");
BizKnowledgeInfoEntity bizKnowledgeInfoEntity = bizKnowledgeInfoService.get(message.getKnowledgeInfoId());
bizKnowledgeInfoEntity.setTrainStatus(KnowledgeConstant.TrainStatus.FAIL);
bizKnowledgeInfoService.update(bizKnowledgeInfoEntity);
logger.warn("-------保存知识库训练失败状态----------");
}
}
......@@ -120,7 +72,6 @@ public class KnowledgeConsumerServiceImpl implements KnowledgeConsumerService {
bizKnowledgeDocumentEntity.setTrainStatus(message.getStatus());
bizKnowledgeDocumentEntity.setKnowledgeId(message.getKnowledgeId());
bizKnowledgeDocumentService.update(message.getKdId(), bizKnowledgeDocumentEntity);
knowledgeProducerService.knowledgeInfoStatusCheck(message);
}
......@@ -141,17 +92,20 @@ public class KnowledgeConsumerServiceImpl implements KnowledgeConsumerService {
logger.info("-------知识库训练状态检查,kdIds:{}-------", kdIds);
for (Integer kdId : kdIdList) {
BizKnowledgeDocumentEntity documentEntity = bizKnowledgeDocumentService.get(kdId);
if (KnowledgeConstant.TrainStatus.FAIL.equals(documentEntity.getTrainStatus())) {
bizKnowledgeInfoEntity.setTrainStatus(KnowledgeConstant.TrainStatus.FAIL);
bizKnowledgeInfoService.update(bizKnowledgeInfoEntity);
}
if (!documentEntity.getTrainStatus().equals(KnowledgeConstant.TrainStatus.COMPLETE)) {
isAllComplete = false;
break;
}
}
if (isAllComplete) {
logger.info("-------知识库训练状态检查,全部完成, knowledgeInfoId:{}-------", knowledgeTrainStatusMessage.getKnowledgeInfoId());
bizKnowledgeInfoEntity.setTrainStatus(KnowledgeConstant.TrainStatus.COMPLETE);
bizKnowledgeInfoService.update(bizKnowledgeInfoEntity);
}
}
}
......@@ -240,7 +240,10 @@ public interface DgtoolsApiConstants {
* 知识库
*/
String TRAIN_KNOWLEDGE = "knowLedgeRest/trainKnowLedge.json";
String TRAIN_KNOWLEDGE_EVENT = "knowLedgeRest/trainKnowLedgeEvent.json";
String TRAIN_KNOWLEDGE_STATUS = "/knowLedgeRest/trainKnowLedgeStatus.json";
String DEL_KNOWLEDGE = "knowLedgeRest/delKnowLedge.json";
String SEARCH_KNOWLEDGE = "knowLedgeRest/searchKnowledge.json";
......
......@@ -19,6 +19,22 @@ public interface DemandKnowledgeService {
*/
String trainKnowledge(String fileURL, SegmentationConfigRequest segmentationConfig);
/**
* 训练知识库-异步
*
* @param fileURL 训练文档
* @return 知识库id
*/
String trainKnowledgeEvent(String fileURL, SegmentationConfigRequest segmentationConfig);
/**
* 获取知识库训练状态
*
* @param knowledgeId
* @return 训练状态
*/
String trainKnowledgeStatus(String knowledgeId);
/**
* 删除知识库
*
......@@ -40,9 +56,10 @@ public interface DemandKnowledgeService {
* 获取知识库分片
*
* @param knowledgeIds 知识库id
* @param query 查询文本
* @param pagingInfo 分页信息
*/
GetKnowledgeChunkInfoResult getKnowledgeChunkInfos(List<String> knowledgeIds, PagingInfo pagingInfo);
GetKnowledgeChunkInfoResult getKnowledgeChunkInfos(List<String> knowledgeIds, String query, PagingInfo pagingInfo);
/**
* 开关知识库分片
......
......@@ -40,6 +40,31 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
return trainKnowledgeResult.getKnowledgeId();
}
@Override
public String trainKnowledgeEvent(String fileURL, SegmentationConfigRequest segmentationConfig) {
Assert.notBlank(fileURL);
TrainKnowledgeRequest request = new TrainKnowledgeRequest();
request.setDocumentUrl(fileURL);
request.setSegmentationConfig(segmentationConfig);
TrainKnowledgeResult trainKnowledgeResult = dgToolsAbstractHttpClient.doRequest(DgtoolsApiConstants.DgtoolsAI.TRAIN_KNOWLEDGE_EVENT, request, getHeaders());
if (null == trainKnowledgeResult) {
throw new BusinessException("train knowledge error");
}
return trainKnowledgeResult.getKnowledgeId();
}
@Override
public String trainKnowledgeStatus(String knowledgeId) {
Assert.notBlank(knowledgeId);
TrainKnowledgeStatusRequest request = new TrainKnowledgeStatusRequest();
request.setKnowledgeId(knowledgeId);
TrainKnowledgeStatusResult trainKnowledgeStatusResult = dgToolsAbstractHttpClient.doRequest(DgtoolsApiConstants.DgtoolsAI.TRAIN_KNOWLEDGE_STATUS, request, getHeaders());
if (null == trainKnowledgeStatusResult) {
throw new BusinessException("get knowledge train status error");
}
return trainKnowledgeStatusResult.getTrainStatus();
}
@Override
public void delKnowledge(String knowledgeId) {
Assert.notBlank(knowledgeId);
......@@ -72,9 +97,10 @@ public class DemandKnowledgeServiceImpl implements DemandKnowledgeService {
}
@Override
public GetKnowledgeChunkInfoResult getKnowledgeChunkInfos(List<String> knowledgeIds, PagingInfo pagingInfo) {
public GetKnowledgeChunkInfoResult getKnowledgeChunkInfos(List<String> knowledgeIds, String query, PagingInfo pagingInfo) {
GetKnowledgeChunkInfoRequest request = new GetKnowledgeChunkInfoRequest();
request.setKnowledgeIds(knowledgeIds);
request.setQuery(query);
return dgToolsAbstractHttpClient.doRequest(DgtoolsApiConstants.DgtoolsAI.GET_KNOWLEDGE_CHUNK_INFOS, request, getHeaders(), pagingInfo);
}
......
......@@ -12,19 +12,28 @@ import java.util.List;
public class Message {
private List<MultiContent> content;
// private List<MultiContent> content;
private Object content;
private String role;
private List<FunctionCall> function_call;
private String name;
public List<MultiContent> getContent() {
// public List<MultiContent> getContent() {
// return content;
// }
//
// public void setContent(List<MultiContent> content) {
// this.content = content;
// }
public Object getContent() {
return content;
}
public void setContent(List<MultiContent> content) {
public void setContent(Object content) {
this.content = content;
}
......
package cn.com.poc.thirdparty.resource.demand.ai.constants;
public interface KnowledgeTrainStatusConstant {
String unTrain = "unTrain";
String line = "line";
String train = "train";
String fail = "fail";
String success = "success";
}
......@@ -9,6 +9,8 @@ public class GetKnowledgeChunkInfoRequest extends AbstractRequest<GetKnowledgeCh
private List<String> knowledgeIds;
private String query;
public List<String> getKnowledgeIds() {
return knowledgeIds;
}
......@@ -17,6 +19,14 @@ public class GetKnowledgeChunkInfoRequest extends AbstractRequest<GetKnowledgeCh
this.knowledgeIds = knowledgeIds;
}
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
@Override
public String getMethod() throws Exception {
return null;
......
......@@ -9,8 +9,17 @@ public class GetKnowledgeChunkInfoResult extends AbstractResult implements Seria
private static final long serialVersionUID = 11243413567468L;
private Integer totalChunk;
private List<ChunkInfo> chunkInfos;
public Integer getTotalChunk() {
return totalChunk;
}
public void setTotalChunk(Integer totalChunk) {
this.totalChunk = totalChunk;
}
public List<ChunkInfo> getChunkInfos() {
return chunkInfos;
......@@ -22,8 +31,9 @@ public class GetKnowledgeChunkInfoResult extends AbstractResult implements Seria
@Override
public String toString() {
return "{" +
"chunkInfos:" + chunkInfos +
return "GetKnowledgeChunkInfoResult{" +
"totalChunk=" + totalChunk +
", chunkInfos=" + chunkInfos +
'}';
}
}
package cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge;
import cn.com.poc.support.dgTools.request.AbstractRequest;
import java.io.Serializable;
public class TrainKnowledgeStatusRequest extends AbstractRequest<TrainKnowledgeStatusResult> implements Serializable {
private String knowledgeId;
public String getKnowledgeId() {
return knowledgeId;
}
public void setKnowledgeId(String knowledgeId) {
this.knowledgeId = knowledgeId;
}
@Override
public String getMethod() throws Exception {
return null;
}
}
package cn.com.poc.thirdparty.resource.demand.ai.entity.knowledge;
import cn.com.poc.support.dgTools.result.AbstractResult;
import java.io.Serializable;
public class TrainKnowledgeStatusResult extends AbstractResult implements Serializable {
private String trainStatus;
public String getTrainStatus() {
return trainStatus;
}
public void setTrainStatus(String trainStatus) {
this.trainStatus = trainStatus;
}
}
package cn.com.poc.user.convert;
import cn.com.poc.user.dto.MemberInfoDto;
import cn.com.poc.user.entity.MemberInfoEntity;
import cn.com.poc.user.model.BizMemberInfoModel;
......@@ -43,4 +44,39 @@ public class MemberInfoConvert {
return memberInfoEntity;
}
public static MemberInfoDto converEntity2Dto(MemberInfoEntity memberInfoEntity) {
if (memberInfoEntity == null) {
return null;
}
MemberInfoDto memberInfoDto = new MemberInfoDto();
memberInfoDto.setMemberId(memberInfoEntity.getMemberId());
memberInfoDto.setAccount(memberInfoEntity.getAccount());
memberInfoDto.setNickName(memberInfoEntity.getNickName());
memberInfoDto.setAvatarUrl(memberInfoEntity.getAvatarUrl());
memberInfoDto.setMobilePhone(memberInfoEntity.getMobilePhone());
memberInfoDto.setEmail(memberInfoEntity.getEmail());
memberInfoDto.setRemark(memberInfoEntity.getRemark());
memberInfoDto.setLastLoginTime(memberInfoEntity.getLastLoginTime());
memberInfoDto.setShareCode(memberInfoEntity.getShareCode());
memberInfoDto.setModelState(memberInfoEntity.getModelState());
return memberInfoDto;
}
public static MemberInfoEntity convertDto2Entity(MemberInfoDto memberInfoDto) {
if (memberInfoDto == null) {
return null;
}
MemberInfoEntity memberInfoEntity = new MemberInfoEntity();
memberInfoEntity.setMemberId(memberInfoDto.getMemberId());
memberInfoEntity.setAccount(memberInfoDto.getAccount());
memberInfoEntity.setNickName(memberInfoDto.getNickName());
memberInfoEntity.setAvatarUrl(memberInfoDto.getAvatarUrl());
memberInfoEntity.setMobilePhone(memberInfoDto.getMobilePhone());
memberInfoEntity.setEmail(memberInfoDto.getEmail());
memberInfoEntity.setRemark(memberInfoDto.getRemark());
memberInfoEntity.setLastLoginTime(memberInfoDto.getLastLoginTime());
memberInfoEntity.setShareCode(memberInfoDto.getShareCode());
memberInfoEntity.setModelState(memberInfoDto.getModelState());
return memberInfoEntity;
}
}
\ No newline at end of file
package cn.com.poc.user.dto;
import cn.com.yict.framemax.data.model.BaseModelClass;
import java.util.Date;
/**
* @Author:Roger Wu
* @Date:2024-07-25 11:06
*/
public class MemberInfoDto extends BaseModelClass {
/**
* member_id
* 会员id
*/
private Integer memberId;
public Integer getMemberId() {
return this.memberId;
}
public void setMemberId(Integer memberId) {
this.memberId = memberId;
}
/**
* account
* 账号
*/
private String account;
public String getAccount() {
return this.account;
}
public void setAccount(String account) {
this.account = account;
}
/**
* nick_name
* 用户昵称
*/
private String nickName;
public String getNickName() {
return this.nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
/**
* avatar_url
* 用户头像图片的 URL
*/
private String avatarUrl;
public String getAvatarUrl() {
return this.avatarUrl;
}
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
/**
* mobile_phone
* 用户手机号
*/
private String mobilePhone;
public String getMobilePhone() {
return this.mobilePhone;
}
public void setMobilePhone(String mobilePhone) {
this.mobilePhone = mobilePhone;
}
/**
* email
* 用户邮箱
*/
private String email;
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
/**
* remark
* 备注
*/
private String remark;
public String getRemark() {
return this.remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
/** last_login_time
*用户账号
*/
private Date lastLoginTime;
public Date getLastLoginTime() {
return lastLoginTime;
}
public void setLastLoginTime(Date lastLoginTime) {
this.lastLoginTime = lastLoginTime;
}
private String shareCode;
public String getShareCode() {
return shareCode;
}
public void setShareCode(String shareCode) {
this.shareCode = shareCode;
}
}
package cn.com.poc.user.rest;
import cn.com.poc.user.dto.MemberInfoDto;
import cn.com.poc.user.dto.MemberLoginRequestDto;
import cn.com.poc.user.dto.MemberLoginResponseDto;
import cn.com.poc.user.dto.MemberPasswordRequestDto;
......@@ -33,4 +34,11 @@ public interface BizMemberInfoRest extends BaseRest {
*/
@Permission(Access.Anonymous)
void forgetMemberPassword(@RequestBody MemberPasswordRequestDto memberPasswordRequestDto) throws Exception;
/**
* 获取用户信息
*
* @return
*/
MemberInfoDto getCurrentMemberInfo() throws Exception;
}
\ No newline at end of file
......@@ -3,13 +3,17 @@ package cn.com.poc.user.rest.impl;
import javax.annotation.Resource;
import cn.com.poc.common.utils.Assert;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.support.security.oauth.constants.OauthConstants;
import cn.com.poc.user.convert.MemberInfoConvert;
import cn.com.poc.user.dto.MemberInfoDto;
import cn.com.poc.user.dto.MemberLoginRequestDto;
import cn.com.poc.user.dto.MemberLoginResponseDto;
import cn.com.poc.user.dto.MemberPasswordRequestDto;
import cn.com.poc.user.aggregation.MemberInfoService;
import cn.com.poc.user.builder.LoginChannelBuilder;
import cn.com.poc.user.entity.MemberInfoEntity;
import cn.com.poc.user.service.BizMemberInfoService;
import cn.com.yict.framemax.security.oauth.OauthAccesstokenManager;
import cn.com.yict.framemax.security.oauth.entity.OauthResultEntity;
import org.springframework.stereotype.Component;
......@@ -27,6 +31,9 @@ public class BizMemberInfoRestImpl implements BizMemberInfoRest {
@Resource
private MemberInfoService memberInfoService;
@Resource
private BizMemberInfoService bizMemberInfoService;
/**
* 用户登录
......@@ -93,4 +100,15 @@ public class BizMemberInfoRestImpl implements BizMemberInfoRest {
memberInfoService.configureMemberPassword(memberPasswordRequestDto);
}
/**
* 获取用户信息
*
* @return
*/
@Override
public MemberInfoDto getCurrentMemberInfo() throws Exception {
MemberInfoEntity memberInfoEntity = bizMemberInfoService.getById(BlContext.getCurrentUser().getUserId().intValue());
return MemberInfoConvert.converEntity2Dto(memberInfoEntity);
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package cn.com.poc;
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.yict.framemax.core.spring.SingleContextInitializer;
import com.google.common.collect.Lists;
......@@ -30,6 +32,9 @@ public class AgentApplicationInfoTest {
@Resource
private DemandKnowledgeService demandKnowledgeService;
@Resource
private RedisService redisService;
/**
* Agent 应用标题,描述生成
*/
......@@ -46,4 +51,19 @@ public class AgentApplicationInfoTest {
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