Browse Source

add:调整逻辑,兼容文件与url,增加配置信息的管理

zhongwei
luyie 3 months ago
parent
commit
be39e6f21b
  1. 1
      .gitignore
  2. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java
  3. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java
  4. 39
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java
  5. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuController.java
  6. 34
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java
  7. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java
  8. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java
  9. 7
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java
  10. 35
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerTest.java
  11. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java
  12. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java
  13. 8
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisService.java
  14. 15
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java
  15. 33
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java
  16. 45
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/utils/ZhipuUtil.java
  17. 11
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java
  18. 2
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java
  19. 50
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java

1
.gitignore vendored

@ -2,6 +2,7 @@
/hzims-biz-common/target /hzims-biz-common/target
/hzims-service/*/target /hzims-service/*/target
/hzims-service-api/*/target /hzims-service-api/*/target
target
log log
*.iml *.iml

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/api/feign/BigModelAnalysisClient.java

@ -2,7 +2,7 @@ package com.hnac.hzims.bigmodel.api.feign;
import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisDTO; import com.hnac.hzims.bigmodel.api.dto.BigModelAnalysisDTO;
import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService; import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService;
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisRequest; import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -21,6 +21,6 @@ public class BigModelAnalysisClient implements IBigModelAnalysisClient {
@Override @Override
@PostMapping(PREFIX_API + "/analysis") @PostMapping(PREFIX_API + "/analysis")
public R analysis(BigModelAnalysisDTO analysisInfo) { public R analysis(BigModelAnalysisDTO analysisInfo) {
return R.data(analysisService.analysis(ZhipuAnalysisRequest.of(analysisInfo))); return R.data(analysisService.analysis(ZhipuAnalysisFileRequest.of(analysisInfo)));
} }
} }

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/config/ZhipuAiConfigProperties.java

@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
* @Date: 2024/8/8 14:03 * @Date: 2024/8/8 14:03
*/ */
@Data @Data
@ConfigurationProperties(prefix = "zhipuai") @ConfigurationProperties(prefix = "bigmodel.zhipuai")
public class ZhipuAiConfigProperties { public class ZhipuAiConfigProperties {
private String apiSecret; private String apiSecret;

39
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuAnalysisInfoController.java

@ -0,0 +1,39 @@
package com.hnac.hzims.bigmodel.zhipuai.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService;
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @Author: ypj
* @Date: 2024/8/12 20:22
*/
@RestController
@Api(value = "智谱分析信息管理", tags = "智谱分析信息管理")
@RequestMapping("/zhipu/info")
@AllArgsConstructor
public class ZhipuAnalysisInfoController {
private final ZhipuAnalysisInfoService analysisInfoService;
@PostMapping("/save")
@ApiOperation("保存智谱分析信息")
@ApiOperationSupport(order = 1)
public R<Boolean> save(@RequestBody @Validated ZhipuAnalysisInfoVO request) {
return R.status(analysisInfoService.save(request.toEntity()));
}
@GetMapping("/remove")
@ApiOperation("批量删除智谱分析信息")
@ApiOperationSupport(order = 2)
public R<Boolean> remove (@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) {
return R.status(analysisInfoService.removeByIds(Func.toLongList(",",ids)));
}
}

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/controller/ZhipuController.java

@ -2,8 +2,8 @@ package com.hnac.hzims.bigmodel.zhipuai.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService; import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService;
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisRequest; import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest;
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisResponse; import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileResponse;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -30,7 +30,7 @@ public class ZhipuController {
@PostMapping("/analysis") @PostMapping("/analysis")
@ApiOperation("分析") @ApiOperation("分析")
@ApiOperationSupport(order = 1) @ApiOperationSupport(order = 1)
public R<ZhipuAnalysisResponse> analysis(@RequestBody @Valid ZhipuAnalysisRequest request) { public R<ZhipuAnalysisFileResponse> analysis(@RequestBody @Valid ZhipuAnalysisFileRequest request) {
return R.data(analysisService.analysis(request)); return R.data(analysisService.analysis(request));
} }
} }

34
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/entity/ZhipuAnalysisInfoEntity.java

@ -1,25 +1,53 @@
package com.hnac.hzims.bigmodel.zhipuai.entity; package com.hnac.hzims.bigmodel.zhipuai.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseEntity;
/** /**
* @Author: ypj * @Author: ypj
* @Date: 2024/8/8 15:17 * @Date: 2024/8/8 15:17
*/ */
@ApiModel(value ="大模型分析信息")
@Data @Data
@EqualsAndHashCode(callSuper = false)
@TableName("hzims_analysis_info")
public class ZhipuAnalysisInfoEntity extends BaseEntity { public class ZhipuAnalysisInfoEntity extends BaseEntity {
private String resultType; @ApiModelProperty(value = "策略编码")
@TableField("CODE")
private String code;
@ApiModelProperty(value = "策略名称")
@TableField("NAME")
private String name; private String name;
private String code; @ApiModelProperty(value = "调用模型名称")
@TableField("MODEL")
private String model; private String model;
@ApiModelProperty(value = "模型交互内容")
@TableField("REQUEST_CONTENT")
private String requestContent; private String requestContent;
@ApiModelProperty(value = "结果解析策略")
@TableField("RESULT_STRATEGY")
private String resultStrategy; private String resultStrategy;
@ApiModelProperty(value = "结果类型")
@TableField("RESULT_TYPE")
private String resultType;
@ApiModelProperty(value = "结果查询key值")
@TableField("RESULT_KEY")
private String resultKey;
@ApiModelProperty(value = "结果对比内容")
@TableField("RESULT_CONDITION")
private String resultCondition;
} }

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/AbstractZhipuAnalysisHandler.java

@ -16,8 +16,4 @@ public abstract class AbstractZhipuAnalysisHandler implements ZhipuAnalyser {
@Resource @Resource
protected ClientV4 client; protected ClientV4 client;
@Override
public String getBase64(String url) {
return Base64.getEncoder().encodeToString(getFileBytes(url));
}
} }

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalyser.java

@ -8,10 +8,6 @@ import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
*/ */
public interface ZhipuAnalyser<Req, Resp> { public interface ZhipuAnalyser<Req, Resp> {
String getBase64(String url);
byte[] getFileBytes(String url);
String getAnalysisStrategy(); String getAnalysisStrategy();
String getAnalysisModel(); String getAnalysisModel();

7
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerGlm4v.java

@ -38,11 +38,6 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler {
} }
@Override @Override
public byte[] getFileBytes(String url) {
return new byte[0];
}
@Override
public ModelApiResponse sendRequest(ZhipuAnalysisInfoEntity info, String url) { public ModelApiResponse sendRequest(ZhipuAnalysisInfoEntity info, String url) {
ChatCompletionRequest request = getRequest(info, url); ChatCompletionRequest request = getRequest(info, url);
log.info("send zhipu ai request :{}", request); log.info("send zhipu ai request :{}", request);
@ -59,7 +54,7 @@ public class ZhipuAnalysisHandlerGlm4v extends AbstractZhipuAnalysisHandler {
Map<String, Object> typeMap = new HashMap<>(); Map<String, Object> typeMap = new HashMap<>();
typeMap.put("type", "image_url"); typeMap.put("type", "image_url");
Map<String, Object> urlMap = new HashMap<>(); Map<String, Object> urlMap = new HashMap<>();
urlMap.put("url", getBase64(url)); urlMap.put("url", url);
typeMap.put("image_url", urlMap); typeMap.put("image_url", urlMap);
contentList.add(textMap); contentList.add(textMap);
contentList.add(typeMap); contentList.add(typeMap);

35
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/handler/ZhipuAnalysisHandlerTest.java

@ -1,22 +1,9 @@
package com.hnac.hzims.bigmodel.zhipuai.handler; package com.hnac.hzims.bigmodel.zhipuai.handler;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.zhipu.oapi.Constants;
import com.zhipu.oapi.service.v4.model.ChatCompletionRequest;
import com.zhipu.oapi.service.v4.model.ChatMessage;
import com.zhipu.oapi.service.v4.model.ChatMessageRole;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @Author: ypj * @Author: ypj
* @Date: 2024/8/12 10:11 * @Date: 2024/8/12 10:11
@ -32,26 +19,4 @@ public class ZhipuAnalysisHandlerTest extends ZhipuAnalysisHandlerGlm4v {
return model; return model;
} }
@Override
public byte[] getFileBytes(String url) {
File file = new File(url);
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(file);
byte[] bytes = new byte[(int) file.length()];
fileInputStream.read(bytes);
return bytes;
} catch (Exception e) {
log.error("读取文件出错", e);
} finally {
if (null != fileInputStream) {
try {
fileInputStream.close();
} catch (IOException ignore) {
}
}
}
return null;
}
} }

11
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/mapper/ZhipuAnalysisInfoMapper.java

@ -0,0 +1,11 @@
package com.hnac.hzims.bigmodel.zhipuai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
/**
* @Author: ypj
* @Date: 2024/8/12 20:05
*/
public interface ZhipuAnalysisInfoMapper extends BaseMapper<ZhipuAnalysisInfoEntity> {
}

11
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisInfoService.java

@ -0,0 +1,11 @@
package com.hnac.hzims.bigmodel.zhipuai.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
/**
* @Author: ypj
* @Date: 2024/8/12 20:03
*/
public interface ZhipuAnalysisInfoService extends IService<ZhipuAnalysisInfoEntity> {
}

8
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/ZhipuAnalysisService.java

@ -1,8 +1,8 @@
package com.hnac.hzims.bigmodel.zhipuai.service; package com.hnac.hzims.bigmodel.zhipuai.service;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisRequest; import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest;
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisResponse; import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileResponse;
/** /**
* @Author: ypj * @Author: ypj
@ -10,7 +10,7 @@ import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisResponse;
*/ */
public interface ZhipuAnalysisService { public interface ZhipuAnalysisService {
ZhipuAnalysisResponse analysis(ZhipuAnalysisRequest request); ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request);
ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisRequest request); ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request);
} }

15
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisInfoServiceImpl.java

@ -0,0 +1,15 @@
package com.hnac.hzims.bigmodel.zhipuai.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.hnac.hzims.bigmodel.zhipuai.mapper.ZhipuAnalysisInfoMapper;
import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService;
import org.springframework.stereotype.Service;
/**
* @Author: ypj
* @Date: 2024/8/12 20:03
*/
@Service
public class ZhipuAnalysisInfoServiceImpl extends ServiceImpl<ZhipuAnalysisInfoMapper, ZhipuAnalysisInfoEntity> implements ZhipuAnalysisInfoService {
}

33
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java

@ -4,11 +4,15 @@ import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalyser; import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalyser;
import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalysisFactory; import com.hnac.hzims.bigmodel.zhipuai.handler.ZhipuAnalysisFactory;
import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService; import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisService;
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisRequest; import com.hnac.hzims.bigmodel.zhipuai.utils.ZhipuUtil;
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisResponse; import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileRequest;
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisFileResponse;
import com.hnac.hzinfo.exception.HzServiceException;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.Objects; import java.util.Objects;
@ -23,17 +27,34 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
private final ZhipuAnalysisFactory analysisFactory; private final ZhipuAnalysisFactory analysisFactory;
@Override @Override
public ZhipuAnalysisResponse analysis(ZhipuAnalysisRequest request) { public ZhipuAnalysisFileResponse analysis(ZhipuAnalysisFileRequest request) {
Assert.isTrue(StringUtil.isBlank(request.getFilePath()) && StringUtil.isBlank(request.getFileContent()) && StringUtil.isBlank(request.getUrl()), () -> {
throw new HzServiceException("文件为空");
});
ZhipuAnalysisInfoEntity info = getAnalysisInfo(request); ZhipuAnalysisInfoEntity info = getAnalysisInfo(request);
ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(info.getModel()); ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(info.getModel());
String resultStr = analyser.getResult(info, request.getUrl());
ZhipuAnalysisResponse response = new ZhipuAnalysisResponse(); String resultStr = analyser.getResult(info, getSendUrl(request));
ZhipuAnalysisFileResponse response = new ZhipuAnalysisFileResponse();
response.setResultStr(resultStr); response.setResultStr(resultStr);
return response; return response;
} }
String getSendUrl(ZhipuAnalysisFileRequest request) {
if (StringUtil.isNotBlank(request.getUrl())) {
return request.getUrl();
}
if (StringUtil.isNotBlank(request.getFileContent())) {
return request.getFileContent();
}
if (StringUtil.isNotBlank(request.getFilePath())) {
return ZhipuUtil.getBase64(request.getFilePath());
}
return null;
}
@Override @Override
public ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisRequest request) { public ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request) {
if (Objects.isNull(request.getCode())) { if (Objects.isNull(request.getCode())) {
return request.toAnalysisInfo(); return request.toAnalysisInfo();
} }

45
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/utils/ZhipuUtil.java

@ -0,0 +1,45 @@
package com.hnac.hzims.bigmodel.zhipuai.utils;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Base64;
/**
* @Author: ypj
* @Date: 2024/8/12 21:07
*/
@Slf4j
public class ZhipuUtil {
public static byte[] getFileBytes(String filePath) {
File file = new File(filePath);
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(file);
byte[] bytes = new byte[(int) file.length()];
fileInputStream.read(bytes);
return bytes;
} catch (Exception e) {
log.error("读取文件出错", e);
} finally {
if (null != fileInputStream) {
try {
fileInputStream.close();
} catch (IOException ignore) {
}
}
}
return null;
}
public static String getBase64(byte[] bytes) {
return Base64.getEncoder().encodeToString(bytes);
}
public static String getBase64(String filePath) {
return getBase64(getFileBytes(filePath));
}
}

11
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisRequest.java → hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileRequest.java

@ -12,7 +12,7 @@ import lombok.Data;
*/ */
@Data @Data
@ApiModel(value = "智谱分析请求", description = "智谱分析请求") @ApiModel(value = "智谱分析请求", description = "智谱分析请求")
public class ZhipuAnalysisRequest { public class ZhipuAnalysisFileRequest {
@ApiModelProperty("策略编码") @ApiModelProperty("策略编码")
private String code; private String code;
@ -25,6 +25,9 @@ public class ZhipuAnalysisRequest {
@ApiModelProperty("本地文件路径") @ApiModelProperty("本地文件路径")
private String filePath; private String filePath;
@ApiModelProperty("文件内容")
private String fileContent;
@ApiModelProperty("发送内容") @ApiModelProperty("发送内容")
private String content; private String content;
@ -33,14 +36,14 @@ public class ZhipuAnalysisRequest {
public ZhipuAnalysisInfoEntity toAnalysisInfo() { public ZhipuAnalysisInfoEntity toAnalysisInfo() {
ZhipuAnalysisInfoEntity info = new ZhipuAnalysisInfoEntity(); ZhipuAnalysisInfoEntity info = new ZhipuAnalysisInfoEntity();
info.setCode(this.getCode());
info.setModel(this.getModel()); info.setModel(this.getModel());
info.setRequestContent(this.content); info.setRequestContent(this.content);
info.setModel(this.getModel());
return info; return info;
} }
public static ZhipuAnalysisRequest of(BigModelAnalysisDTO analysisDTO) { public static ZhipuAnalysisFileRequest of(BigModelAnalysisDTO analysisDTO) {
ZhipuAnalysisRequest request = new ZhipuAnalysisRequest(); ZhipuAnalysisFileRequest request = new ZhipuAnalysisFileRequest();
request.setCode(analysisDTO.getCode()); request.setCode(analysisDTO.getCode());
request.setUrl(analysisDTO.getUrl()); request.setUrl(analysisDTO.getUrl());
return request; return request;

2
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisResponse.java → hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisFileResponse.java

@ -10,7 +10,7 @@ import lombok.Data;
*/ */
@Data @Data
@ApiModel(value = "智谱分析返回",description = "智谱分析返回") @ApiModel(value = "智谱分析返回",description = "智谱分析返回")
public class ZhipuAnalysisResponse { public class ZhipuAnalysisFileResponse {
@ApiModelProperty("返回结果") @ApiModelProperty("返回结果")
String resultStr; String resultStr;

50
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/zhipuai/vo/ZhipuAnalysisInfoVO.java

@ -0,0 +1,50 @@
package com.hnac.hzims.bigmodel.zhipuai.vo;
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tool.utils.BeanUtil;
import javax.validation.constraints.NotNull;
/**
* @Author: ypj
* @Date: 2024/8/8 15:17
*/
@ApiModel(value = "大模型分析信息")
@Data
@EqualsAndHashCode(callSuper = false)
public class ZhipuAnalysisInfoVO {
@ApiModelProperty(value = "策略编码")
@NotNull
private String code;
@ApiModelProperty(value = "策略名称")
private String name;
@ApiModelProperty(value = "调用模型名称")
@NotNull
private String model;
@ApiModelProperty(value = "模型交互内容")
private String requestContent;
@ApiModelProperty(value = "结果解析策略")
private String resultStrategy;
@ApiModelProperty(value = "结果类型")
private String resultType;
@ApiModelProperty(value = "结果查询key值")
private String resultKey;
@ApiModelProperty(value = "结果对比内容")
private String resultCondition;
public ZhipuAnalysisInfoEntity toEntity() {
return BeanUtil.copy(this, ZhipuAnalysisInfoEntity.class);
}
}
Loading…
Cancel
Save