diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java index 8176304..8a51335 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java @@ -2,7 +2,6 @@ package com.hnac.gglm.bigmodel.zhipuai.handler; import cn.hutool.core.lang.Assert; import com.hnac.gglm.bigmodel.zhipuai.constants.ErrorCode; -import com.hnac.hzims.common.utils.FileUtil; import com.hnac.hzinfo.exception.HzServiceException; import com.zhipu.oapi.Constants; import com.zhipu.oapi.service.v4.model.ChatCompletionRequest; @@ -12,7 +11,6 @@ import com.zhipu.oapi.service.v4.model.ModelApiResponse; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.jackson.JsonUtil; -import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; import java.util.*; @@ -39,18 +37,12 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { @Override public ModelApiResponse sendRequest(String text, String url) { ChatCompletionRequest request = getRequest(text, url); - log.info("send zhipu ai request ,text is {},url is {}", text, url); + log.info("send zhipu ai request ,text is {}", text); return client.invokeModelApi(request); } @Override public ChatCompletionRequest getRequest(String text, String url) { - String base64 = null; - try { - base64 = FileUtil.getBase64(FileUtil.getUrlByteByRequest(url)); - } catch (Exception e) { - log.info("get base64 error", e); - } List messages = new ArrayList<>(); List> contentList = new ArrayList<>(); Map textMap = new HashMap<>(); @@ -59,7 +51,7 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { Map typeMap = new HashMap<>(); typeMap.put("type", "image_url"); Map urlMap = new HashMap<>(); - urlMap.put("url", StringUtil.isBlank(base64) ? url : base64); + urlMap.put("url", url); typeMap.put("image_url", urlMap); contentList.add(textMap); contentList.add(typeMap); 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 db67772..6c83614 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 @@ -7,9 +7,9 @@ import com.hnac.gglm.bigmodel.zhipuai.constants.BaseEnum; import com.hnac.gglm.bigmodel.zhipuai.constants.ErrorCode; import com.hnac.gglm.bigmodel.zhipuai.constants.ResultStrategyType; import com.hnac.gglm.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; -import com.hnac.gglm.bigmodel.zhipuai.handler.result.ResultStrategy; import com.hnac.gglm.bigmodel.zhipuai.handler.ZhipuAnalyser; import com.hnac.gglm.bigmodel.zhipuai.handler.ZhipuAnalysisFactory; +import com.hnac.gglm.bigmodel.zhipuai.handler.result.ResultStrategy; import com.hnac.gglm.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; import com.hnac.gglm.bigmodel.zhipuai.service.ZhipuAnalysisService; import com.hnac.gglm.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest; @@ -99,7 +99,13 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { String getSendUrl(ZhipuAnalysisFileRequest request) { if (StringUtil.isNotBlank(request.getUrl())) { - return 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; } Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()), () -> { throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException();