Commit b9bc3a01 authored by alex yao's avatar alex yao

fix: 【【POE】-【应用】web端和移动端使用提取文字插件报“null”】 --bug=1009892

parent 7f9c9ab0
...@@ -259,7 +259,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -259,7 +259,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
// 判断是否调用function // 判断是否调用function
//计算扣分数 //计算扣分数
CheckPluginUseEntity checkPluginUseEntity = AgentApplicationTools.checkPluginUse(dto.getMessages(), tools); CheckPluginUseEntity checkPluginUseEntity = AgentApplicationTools.checkPluginUse(dto.getMessages(), tools,fileUrls,imageUrls);
Long pointDeductionNum = pointDeductionRulesService.calculatePointDeductionNum(model, infoEntity.getCommunicationTurn(), checkPluginUseEntity.getDeductionTools()); Long pointDeductionNum = pointDeductionRulesService.calculatePointDeductionNum(model, infoEntity.getCommunicationTurn(), checkPluginUseEntity.getDeductionTools());
AgentUseModifyEventInfo agentUseModifyEventInfo = new AgentUseModifyEventInfo(); AgentUseModifyEventInfo agentUseModifyEventInfo = new AgentUseModifyEventInfo();
agentUseModifyEventInfo.setAgentId(agentId); agentUseModifyEventInfo.setAgentId(agentId);
......
...@@ -22,10 +22,7 @@ import org.apache.commons.lang.ArrayUtils; ...@@ -22,10 +22,7 @@ import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author alex.yao * @author alex.yao
...@@ -162,13 +159,27 @@ public class AgentApplicationTools { ...@@ -162,13 +159,27 @@ public class AgentApplicationTools {
/** /**
* 判断将会调用的插件-用于扣减积分 * 判断将会调用的插件-用于扣减积分
*/ */
public static CheckPluginUseEntity checkPluginUse(List<Message> messages, List<Tool> tools) { public static CheckPluginUseEntity checkPluginUse(List<Message> messages, List<Tool> tools, List<String> fileUrls, List<String> imageUrls) {
CheckPluginUseEntity checkPluginUseEntity = new CheckPluginUseEntity(); CheckPluginUseEntity checkPluginUseEntity = new CheckPluginUseEntity();
if (CollectionUtils.isEmpty(messages) || CollectionUtils.isEmpty(tools)) { if (CollectionUtils.isEmpty(messages) || CollectionUtils.isEmpty(tools)) {
return checkPluginUseEntity; return checkPluginUseEntity;
} }
LLMService llmService = SpringUtils.getBean(LLMService.class); LLMService llmService = SpringUtils.getBean(LLMService.class);
String query = messages.get(messages.size() - 1).getContent().toString(); Object content = messages.get(messages.size() - 1).getContent();
String query;
if (content instanceof List) {
query = ((List<HashMap>) content).get(0).get("text").toString();
} else {
query = content.toString();
}
query = "用户输入:" + query + "\n";
if (CollectionUtils.isNotEmpty(fileUrls)) {
query = query + "用户上传文件地址:" + JsonUtils.serialize(fileUrls) + "\n";
}
if (CollectionUtils.isNotEmpty(imageUrls)) {
query = query + "用户上传图片地址:" + JsonUtils.serialize(imageUrls);
}
List<Tool> deductionTools = new ArrayList<>(); List<Tool> deductionTools = new ArrayList<>();
FunctionCallResult functionCallResult = llmService.functionCall(query, tools.toArray(new Tool[0])); FunctionCallResult functionCallResult = llmService.functionCall(query, tools.toArray(new Tool[0]));
if (functionCallResult != null && functionCallResult.isNeed()) { if (functionCallResult != null && functionCallResult.isNeed()) {
......
...@@ -143,7 +143,7 @@ public class AgentApplicationApiServiceImpl implements AgentApplicationApiServic ...@@ -143,7 +143,7 @@ public class AgentApplicationApiServiceImpl implements AgentApplicationApiServic
//计算扣分数 //计算扣分数
// 判断是否调用function // 判断是否调用function
CheckPluginUseEntity checkPluginUseEntity = AgentApplicationTools.checkPluginUse(messages, tools); CheckPluginUseEntity checkPluginUseEntity = AgentApplicationTools.checkPluginUse(messages, tools, fileUrls, imageUrls);
Long pointDeductionNum = pointDeductionRulesService.calculatePointDeductionNum(infoEntity.getLargeModel(), infoEntity.getCommunicationTurn(), checkPluginUseEntity.getDeductionTools()); Long pointDeductionNum = pointDeductionRulesService.calculatePointDeductionNum(infoEntity.getLargeModel(), infoEntity.getCommunicationTurn(), checkPluginUseEntity.getDeductionTools());
AgentUseModifyEventInfo agentUseModifyEventInfo = new AgentUseModifyEventInfo(); AgentUseModifyEventInfo agentUseModifyEventInfo = new AgentUseModifyEventInfo();
agentUseModifyEventInfo.setAgentId(agentId); agentUseModifyEventInfo.setAgentId(agentId);
......
...@@ -166,7 +166,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService { ...@@ -166,7 +166,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
//计算扣分数 //计算扣分数
// 判断是否调用function // 判断是否调用function
CheckPluginUseEntity checkPluginUseEntity = AgentApplicationTools.checkPluginUse(messages, tools); CheckPluginUseEntity checkPluginUseEntity = AgentApplicationTools.checkPluginUse(messages, tools,fileUrls,imageUrls);
Long pointDeductionNum = pointDeductionRulesService.calculatePointDeductionNum(infoEntity.getLargeModel(), infoEntity.getCommunicationTurn(), checkPluginUseEntity.getDeductionTools()); Long pointDeductionNum = pointDeductionRulesService.calculatePointDeductionNum(infoEntity.getLargeModel(), infoEntity.getCommunicationTurn(), checkPluginUseEntity.getDeductionTools());
AgentUseModifyEventInfo agentUseModifyEventInfo = new AgentUseModifyEventInfo(); AgentUseModifyEventInfo agentUseModifyEventInfo = new AgentUseModifyEventInfo();
agentUseModifyEventInfo.setAgentId(agentId); agentUseModifyEventInfo.setAgentId(agentId);
......
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