Commit 88ca063e authored by alex yao's avatar alex yao

feat:AI+财务 记录function记录

parent b899682f
......@@ -621,7 +621,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
BufferedReader bufferedReader = llmService.chatChunk(largeModelResponse);
SSEUtil sseUtil = new SSEUtil(httpServletResponse);
textOutputStream(sseUtil, bufferedReader);
textOutputStream(sseUtil, bufferedReader, null);
return null;
}
......@@ -642,6 +642,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
private AgentResultEntity llmExecutorAndOutput(Float topP, boolean stream, String model, Message[] messageArray, FunctionResult functionResult, List<KnowledgeContentResult> knowledgeResult, List<DBChainResult> dbChainResults, HttpServletResponse httpServletResponse) throws Exception {
if (stream) {
SSEUtil sseUtil = new SSEUtil(httpServletResponse);
ToolFunction toolFunction = null;
if (CollectionUtils.isNotEmpty(dbChainResults)) {
LargeModelDemandResult result = new LargeModelDemandResult();
result.setCode("0");
......@@ -661,14 +662,14 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
if (ObjectUtil.isNotNull(functionResult) && StringUtils.isNotBlank(functionResult.getFunctionName())) {
LargeModelDemandResult result = new LargeModelDemandResult();
result.setCode("0");
ToolFunction toolFunction = functionResultConvertToolFunction(functionResult);
toolFunction = functionResultConvertToolFunction(functionResult);
result.setFunction(toolFunction);
result.setDbChainResult(null);
result.setKnowledgeContentResult(null);
sseUtil.send(JsonUtils.serialize(result));
}
BufferedReader bufferedReader = invokeLLMStream(model, messageArray, topP);
return textOutputStream(sseUtil, bufferedReader);
return textOutputStream(sseUtil, bufferedReader, toolFunction);
} else {
LargeModelDemandResult largeModelDemandResult = invokeLLM(model, messageArray, topP);
if (ObjectUtil.isNotNull(functionResult) && StringUtils.isNotBlank(functionResult.getFunctionName())) {
......@@ -882,6 +883,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
AgentResultEntity agentResultEntity = new AgentResultEntity();
agentResultEntity.setMessage(largeModelDemandResult.getMessage());
agentResultEntity.setReasoningContent(largeModelDemandResult.getReasoningContent());
agentResultEntity.setFunction(largeModelDemandResult.getFunction());
return agentResultEntity;
}
......@@ -892,7 +894,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
* @param bufferedReader
* @throws IOException
*/
private AgentResultEntity textOutputStream(SSEUtil sseUtil, BufferedReader bufferedReader) {
private AgentResultEntity textOutputStream(SSEUtil sseUtil, BufferedReader bufferedReader, ToolFunction toolFunction) {
String res = "";
StringBuilder output = new StringBuilder();
StringBuilder reasoningContent = new StringBuilder();
......@@ -934,6 +936,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
AgentResultEntity agentResultEntity = new AgentResultEntity();
agentResultEntity.setMessage(output.toString());
agentResultEntity.setReasoningContent(reasoningContent.toString());
agentResultEntity.setFunction(toolFunction);
return agentResultEntity;
}
}
......
......@@ -17,6 +17,7 @@ public class BizAgentApplicationDialoguesRecordConvert {
entity.setReasoningContent(model.getReasoningContent());
entity.setImageUrl(model.getImageUrl());
entity.setFileUrl(model.getFileUrl());
entity.setFunction(model.getFunction());
entity.setDialogsId(model.getDialogsId());
entity.setTimestamp(model.getTimestamp());
entity.setIsDeleted(model.getIsDeleted());
......@@ -37,6 +38,7 @@ public class BizAgentApplicationDialoguesRecordConvert {
model.setDialogsId(entity.getDialogsId());
model.setContent(entity.getContent());
model.setReasoningContent(entity.getReasoningContent());
model.setFunction(entity.getFunction());
model.setImageUrl(entity.getImageUrl());
model.setFileUrl(entity.getFileUrl());
model.setTimestamp(entity.getTimestamp());
......
package cn.com.poc.agent_application.entity;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.ToolFunction;
/**
* @author alex.yao
* @date 2025/2/27
......@@ -10,6 +12,16 @@ public class AgentResultEntity {
private String reasoningContent;
private ToolFunction function;
public ToolFunction getFunction() {
return function;
}
public void setFunction(ToolFunction function) {
this.function = function;
}
public String getMessage() {
return message;
}
......
......@@ -116,6 +116,19 @@ public class BizAgentApplicationDialoguesRecordEntity {
this.fileUrl = fileUrl;
}
/**
* 插件响应数据
*/
private java.lang.String function;
public String getFunction() {
return function;
}
public void setFunction(String function) {
this.function = function;
}
/**
* dialogsId
* 对话ID
......
......@@ -176,6 +176,22 @@ public class BizAgentApplicationDialoguesRecordModel extends BaseModelClass impl
this.fileUrl = fileUrl;
}
/**
* function_result
* 插件响应数据
*/
private java.lang.String function;
@Column(name = "function_result", length = 2147483647)
public java.lang.String getFunction() {
return this.function;
}
public void setFunction(java.lang.String function) {
this.function = function;
super.addValidField("function");
}
/**
* timestamp
* 时间戳
......
......@@ -5,6 +5,7 @@ select
baadr.member_id,
baadr.content,
baadr.reasoning_content,
baadr.function_result,
baadr.image_url,
baadr.`timestamp`,
baap.agent_avatar,
......
......@@ -103,6 +103,20 @@ public class AgentApplicationDialoguesRecordQueryItem extends BaseItemClass impl
this.reasoningContent = reasoningContent;
}
/**
* function
*/
private java.lang.String function;
@Column(name = "function_result")
public String getFunction() {
return function;
}
public void setFunction(String function) {
this.function = function;
}
/**
* image_url
* 图片链接
......
......@@ -13,8 +13,10 @@ import cn.com.poc.ai_dialogues.service.BizAiDialoguesProblemAssociationService;
import cn.com.poc.ai_dialogues.service.BizAiDialoguesService;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.service.BizFileUploadRecordService;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.expose.dto.DialoguesContextDto;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.ToolFunction;
import cn.com.yict.framemax.core.exception.BusinessException;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
......@@ -147,6 +149,9 @@ public class AiDialoguesServiceImpl implements AiDialoguesService {
dto.setRole(value.getRole());
dto.setAgentId(value.getAgentId());
dto.setContent(value.getContent());
if (StringUtils.isNotBlank(value.getFunction())) {
dto.setFunction(JsonUtils.deSerialize(value.getFunction(), ToolFunction.class));
}
dto.setReasoningContent(value.getReasoningContent());
dto.setImageUrl(value.getImageUrl());
dto.setTimestamp(value.getTimestamp());
......
......@@ -10,6 +10,7 @@ import cn.com.poc.ai_dialogues.entity.BizAiDialoguesEntity;
import cn.com.poc.ai_dialogues.service.BizAiDialoguesService;
import cn.com.poc.ai_finance.aggregate.AiFinanceService;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.JsonUtils;
import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.knowledge.aggregate.KnowledgeService;
import cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeSearchTypeEnum;
......@@ -155,6 +156,9 @@ public class AiFinanceServiceImpl implements AiFinanceService {
outputRecord.setAgentId(infoEntity.getAgentId());
outputRecord.setDialogsId(dialoguesId);
outputRecord.setMemberId(userId);
if (agentResultEntity.getFunction() != null) {
outputRecord.setFunction(JsonUtils.serialize(agentResultEntity.getFunction()));
}
outputRecord.setTimestamp(System.currentTimeMillis());
outputRecord.setContent(agentResultEntity.getMessage());
outputRecord.setReasoningContent(agentResultEntity.getReasoningContent());
......
package cn.com.poc.expose.dto;
import cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.ToolFunction;
import java.io.Serializable;
public class DialoguesContextDto implements Serializable {
......@@ -60,6 +62,19 @@ public class DialoguesContextDto implements Serializable {
this.reasoningContent = reasoningContent;
}
/**
* function 响应数据
*/
private ToolFunction function;
public ToolFunction getFunction() {
return function;
}
public void setFunction(ToolFunction function) {
this.function = function;
}
/**
* timestamp
* 时间戳
......
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