Browse Source

add:大模型feign接口

zhongwei
luyie 5 months ago
parent
commit
b00c9d2254
  1. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/dto/BigModelAnalysisDTO.java
  2. 20
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/feign/IBigModelAnalysisClient.java
  3. 26
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java
  4. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java
  5. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java
  6. 13
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisRequest.java

20
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;
}

20
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);
}

26
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)));
}
}

2
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

1
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];

13
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;
}
}

Loading…
Cancel
Save