Commit d60ce0d1 authored by alex yao's avatar alex yao

feat:记录对话的模型推理内容

parent 7ccfc95c
...@@ -171,8 +171,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -171,8 +171,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
@Override @Override
public AgentResultEntity callAgentApplication(String agentId, String dialogueId, String largeModel, public AgentResultEntity callAgentApplication(String agentId, String dialogueId, String largeModel,
String agentSystem, Integer[] kdIds, Integer communicationTurn, Float topP, Float temperature, String agentSystem, Integer[] kdIds, Integer communicationTurn, Float topP, Float temperature,
List<Message> messages, List<Tool> tools, List<String> fileUrls, boolean stream, List<String> imageUrls, HttpServletResponse httpServletResponse) throws Exception { List<Message> messages, List<Tool> tools, List<String> fileUrls, boolean stream, List<String> imageUrls, HttpServletResponse httpServletResponse) throws Exception {
logger.info("Call Agent Application, agentId:{}, dialogueId:{},largeModel:{},agentSystem:{},kdIds:{},communicationTurn:{},topP:{},temperature:{},messages:{}, tools:{}" logger.info("Call Agent Application, agentId:{}, dialogueId:{},largeModel:{},agentSystem:{},kdIds:{},communicationTurn:{},topP:{},temperature:{},messages:{}, tools:{}"
, agentId, dialogueId, largeModel, agentSystem, kdIds, communicationTurn, topP, temperature, messages, tools); , agentId, dialogueId, largeModel, agentSystem, kdIds, communicationTurn, topP, temperature, messages, tools);
...@@ -800,6 +800,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ ...@@ -800,6 +800,8 @@ public class AgentApplicationInfoServiceImpl implements AgentApplicationInfoServ
} }
if (StringUtils.isNotBlank(result.getMessage())) { if (StringUtils.isNotBlank(result.getMessage())) {
output.append(result.getMessage()); output.append(result.getMessage());
}
if (StringUtils.isNotBlank(result.getReasoningContent())) {
reasoningContent.append(result.getReasoningContent()); reasoningContent.append(result.getReasoningContent());
} }
writer.write(EVENT_STREAM_PREFIX + res + "\n\n"); writer.write(EVENT_STREAM_PREFIX + res + "\n\n");
......
...@@ -15,9 +15,10 @@ public interface KnowledgeService { ...@@ -15,9 +15,10 @@ public interface KnowledgeService {
* 上传文档 * 上传文档
* *
* @param documentFiles 文档 * @param documentFiles 文档
* @param knowledgeType 知识库类型
* @return 是否成功 * @return 是否成功
*/ */
List<BizKnowledgeDocumentEntity> uploadDocument(MultipartFile[] documentFiles) throws Exception; List<BizKnowledgeDocumentEntity> uploadDocument(MultipartFile[] documentFiles, String knowledgeType) throws Exception;
/** /**
* 删除文档 * 删除文档
......
...@@ -67,7 +67,7 @@ public class KnowledgeServiceImpl implements KnowledgeService { ...@@ -67,7 +67,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
private BosConfigService bosConfigService; private BosConfigService bosConfigService;
@Override @Override
public List<BizKnowledgeDocumentEntity> uploadDocument(MultipartFile[] documentFiles) throws Exception { public List<BizKnowledgeDocumentEntity> uploadDocument(MultipartFile[] documentFiles, String knowledgeType) throws Exception {
//获取用户类型 //获取用户类型
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException(); UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
String memberId = userBaseEntity.getUserId().toString(); String memberId = userBaseEntity.getUserId().toString();
...@@ -109,7 +109,7 @@ public class KnowledgeServiceImpl implements KnowledgeService { ...@@ -109,7 +109,7 @@ public class KnowledgeServiceImpl implements KnowledgeService {
//保存记录 //保存记录
BizKnowledgeDocumentEntity bizKnowledgeDocumentEntity = new BizKnowledgeDocumentEntity(); BizKnowledgeDocumentEntity bizKnowledgeDocumentEntity = new BizKnowledgeDocumentEntity();
bizKnowledgeDocumentEntity.setOwner(KnowledgeConstant.Owner.USER); bizKnowledgeDocumentEntity.setOwner(KnowledgeConstant.Owner.USER);
bizKnowledgeDocumentEntity.setKnowledgeType(KnowledgeConstant.KnowledgeType.BASE); bizKnowledgeDocumentEntity.setKnowledgeType(knowledgeType);
bizKnowledgeDocumentEntity.setDocumentName(documentName); bizKnowledgeDocumentEntity.setDocumentName(documentName);
bizKnowledgeDocumentEntity.setDocumentUrl(documentUrl); bizKnowledgeDocumentEntity.setDocumentUrl(documentUrl);
bizKnowledgeDocumentEntity.setDocumentSize(fileSizeInBytes); bizKnowledgeDocumentEntity.setDocumentSize(fileSizeInBytes);
......
...@@ -19,9 +19,10 @@ public interface KnowledgeRest extends BaseRest { ...@@ -19,9 +19,10 @@ public interface KnowledgeRest extends BaseRest {
* 上传文档 * 上传文档
* *
* @param documentFiles 文档 * @param documentFiles 文档
* @param knowledgeType 知识库类型
* @return 是否成功 * @return 是否成功
*/ */
List<BizKnowledgeDocumentDto> uploadDocument(@RequestParam("documentFiles") MultipartFile[] documentFiles) throws Exception; List<BizKnowledgeDocumentDto> uploadDocument(@RequestParam("documentFiles") MultipartFile[] documentFiles, @RequestParam(required = false) String knowledgeType) throws Exception;
/** /**
* 删除文档 * 删除文档
......
...@@ -48,7 +48,7 @@ public class KnowledgeRestImpl implements KnowledgeRest { ...@@ -48,7 +48,7 @@ public class KnowledgeRestImpl implements KnowledgeRest {
private MemberEquityService memberEquityService; private MemberEquityService memberEquityService;
@Override @Override
public List<BizKnowledgeDocumentDto> uploadDocument(MultipartFile[] documentFiles) throws Exception { public List<BizKnowledgeDocumentDto> uploadDocument(MultipartFile[] documentFiles, String knowledgeType) throws Exception {
Assert.notEmpty(documentFiles); Assert.notEmpty(documentFiles);
Assert.isTrue(documentFiles.length <= 5); Assert.isTrue(documentFiles.length <= 5);
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException(); UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
...@@ -60,7 +60,7 @@ public class KnowledgeRestImpl implements KnowledgeRest { ...@@ -60,7 +60,7 @@ public class KnowledgeRestImpl implements KnowledgeRest {
if ((documentFiles.length + equityInfo.getUsedKnowledgeNum()) > knowledgeNum) { if ((documentFiles.length + equityInfo.getUsedKnowledgeNum()) > knowledgeNum) {
throw new I18nMessageException("exception/create.num.limit"); throw new I18nMessageException("exception/create.num.limit");
} }
List<BizKnowledgeDocumentEntity> entities = knowledgeService.uploadDocument(documentFiles); List<BizKnowledgeDocumentEntity> entities = knowledgeService.uploadDocument(documentFiles, knowledgeType);
return entities.stream().map(entity -> { return entities.stream().map(entity -> {
BizKnowledgeDocumentDto dto = new BizKnowledgeDocumentDto(); BizKnowledgeDocumentDto dto = new BizKnowledgeDocumentDto();
BeanUtil.copyProperties(entity, dto); BeanUtil.copyProperties(entity, dto);
......
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