diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisDTO.java new file mode 100644 index 0000000..3f0e8a3 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisDTO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.api.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @Author: ypj + * @Date: 2024/8/12 16:02 + */ +@Data +@ApiModel(value = "大模型分析",description = "大模型分析参数") +public class BigModelAnalysisDTO { + + @ApiModelProperty("策略编码") + private String code; + + @ApiModelProperty("文件地址") + private String url; +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java new file mode 100644 index 0000000..da57522 --- /dev/null +++ b/hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.bigmodel.api.feign; + +import com.hnac.hzims.bigmodel.BigModelConstants; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisDTO; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @Author: ypj + * @Date: 2024/8/12 15:57 + */ +@FeignClient(name = BigModelConstants.APP_NAME) +public interface IBigModelAnalysisClient { + String PREFIX_API = "feign/bigModel"; + + @PostMapping(PREFIX_API + "/analysis") + R analysis(@RequestBody BigModelAnalysisDTO analysisInfo); +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java new file mode 100644 index 0000000..381bd06 --- /dev/null +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java @@ -0,0 +1,26 @@ +package com.hnac.hzims.bigmodel.api.feign; + +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisDTO; +import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService; +import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisRequest; +import lombok.AllArgsConstructor; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author: ypj + * @Date: 2024/8/12 16:10 + */ +@RestController +@AllArgsConstructor +public class BigModelAnalysisClient implements IBigModelAnalysisClient { + private final ZhipuAnalysisService analysisService; + + + @Override + @PostMapping(PREFIX_API + "/analysis") + public R analysis(BigModelAnalysisDTO analysisInfo) { + return R.data(analysisService.analysis(ZhipuAnalysisRequest.of(analysisInfo))); + } +} diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java index 9a86c28..f63d689 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java @@ -10,7 +10,7 @@ import java.util.Base64; * @Date: 2024/8/12 8:44 */ public abstract class AbstractZhipuAnalysisHandler implements ZhipuAnalyser { - protected final String requestIdTemplate = "hzims-%d"; + protected final String requestIdTemplate = "big_model-%d"; protected final String resultKey = "结果"; @Resource diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java index 609eaf8..e04838f 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java @@ -37,7 +37,6 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler { return AnalysisModel.GLM_4V.getCode(); } - @Override public byte[] getFileBytes(String url) { return new byte[0]; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisRequest.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisRequest.java index 46b0768..c2fefc1 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisRequest.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisRequest.java @@ -1,5 +1,6 @@ package com.hnac.hzims.bigmodel.zhipuai.vo; +import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisDTO; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -12,7 +13,7 @@ import lombok.Data; @Data @ApiModel(value = "智谱分析请求", description = "智谱分析请求") public class ZhipuAnalysisRequest { - @ApiModelProperty("模型编码") + @ApiModelProperty("策略编码") private String code; @ApiModelProperty("模型名称") @@ -21,6 +22,9 @@ public class ZhipuAnalysisRequest { @ApiModelProperty("文件地址") private String url; + @ApiModelProperty("本地文件路径") + private String filePath; + @ApiModelProperty("发送内容") private String content; @@ -34,4 +38,11 @@ public class ZhipuAnalysisRequest { info.setModel(this.getModel()); return info; } + + public static ZhipuAnalysisRequest of(BigModelAnalysisDTO analysisDTO) { + ZhipuAnalysisRequest request = new ZhipuAnalysisRequest(); + request.setCode(analysisDTO.getCode()); + request.setUrl(analysisDTO.getUrl()); + return request; + } }