Commit 1803590e authored by alex yao's avatar alex yao

fix:插件文件缺失异常

parent b9852218
...@@ -58,6 +58,12 @@ public class DocumentUnderstandIngFunction extends AbstractLargeModelFunction { ...@@ -58,6 +58,12 @@ public class DocumentUnderstandIngFunction extends AbstractLargeModelFunction {
return result; return result;
} }
JSONObject jsonObject = JSON.parseObject(content); JSONObject jsonObject = JSON.parseObject(content);
if (!jsonObject.containsKey("question") || !jsonObject.containsKey("file_url")){
result.setFunctionResult(StringUtils.EMPTY);
result.setPromptContent(StringUtils.EMPTY);
return result;
}
String question = jsonObject.getString("question"); String question = jsonObject.getString("question");
String fileUrl = jsonObject.getString("file_url"); String fileUrl = jsonObject.getString("file_url");
File file = DocumentLoad.downloadURLDocument(fileUrl); File file = DocumentLoad.downloadURLDocument(fileUrl);
......
...@@ -50,6 +50,12 @@ public class ImageOCRFunction extends AbstractLargeModelFunction { ...@@ -50,6 +50,12 @@ public class ImageOCRFunction extends AbstractLargeModelFunction {
public AbstractFunctionResult<String> doFunction(String content, String identifier) { public AbstractFunctionResult<String> doFunction(String content, String identifier) {
AbstractFunctionResult<String> result = new AbstractFunctionResult<>(); AbstractFunctionResult<String> result = new AbstractFunctionResult<>();
JSONObject jsonObject = JSONObject.parseObject(content); JSONObject jsonObject = JSONObject.parseObject(content);
if (!jsonObject.containsKey("query") || !jsonObject.containsKey("image_url")) {
result.setPromptContent(content);
result.setFunctionResult(content);
return result;
}
Message systemMessage = new Message(); Message systemMessage = new Message();
systemMessage.setRole(MessageRoleConstant.system); systemMessage.setRole(MessageRoleConstant.system);
......
...@@ -43,6 +43,11 @@ public class PdfToMDFunction extends AbstractLargeModelFunction { ...@@ -43,6 +43,11 @@ public class PdfToMDFunction extends AbstractLargeModelFunction {
public AbstractFunctionResult<String> doFunction(String content, String identifier) { public AbstractFunctionResult<String> doFunction(String content, String identifier) {
AbstractFunctionResult<String> result = new AbstractFunctionResult<String>(); AbstractFunctionResult<String> result = new AbstractFunctionResult<String>();
JSONObject jsonObject = JSONObject.parseObject(content); JSONObject jsonObject = JSONObject.parseObject(content);
if (!jsonObject.containsKey("file_url")) {
result.setPromptContent(content);
result.setFunctionResult(content);
return result;
}
String url = jsonObject.getString("file_url"); String url = jsonObject.getString("file_url");
byte[] fileContent = url.getBytes(StandardCharsets.UTF_8); byte[] fileContent = url.getBytes(StandardCharsets.UTF_8);
HashMap<String, Object> options = new HashMap<>(); HashMap<String, Object> options = new HashMap<>();
......
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