diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java index 6c83614..6bbca9c 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java @@ -97,15 +97,9 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { return response; } - String getSendUrl(ZhipuAnalysisFileRequest request) { + public String getSendUrl(ZhipuAnalysisFileRequest request) { if (StringUtil.isNotBlank(request.getUrl())) { - String base64 = null; - try { - base64 = FileUtil.getBase64(FileUtil.getUrlByteByRequest(request.getUrl())); - } catch (Exception e) { - log.info("get base64 error", e); - } - return StringUtil.isBlank(base64) ? request.getUrl() : base64; + return getBase64FromUrl(request.getUrl()); } Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()), () -> { throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); @@ -117,6 +111,16 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { } } + public String getBase64FromUrl(String url) { + String base64 = null; + try { + base64 = FileUtil.getBase64(FileUtil.getUrlByteByRequest(url)); + } catch (Exception e) { + log.info("get base64 error", e); + } + return StringUtil.isBlank(base64) ? url : base64; + } + @Override public ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request) { ZhipuAnalysisInfoEntity result = null; @@ -151,7 +155,7 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(infoList.get(0).getModel()); String text = getMultiAnalyserText(infoList); - Map resultMap = analyser.getResultMap(text, request.getUrl()); + Map resultMap = analyser.getResultMap(text, getBase64FromUrl(request.getUrl())); if (null == resultMap) { response.setCode(ResultCode.FAILURE.getCode());