Browse Source

fix:解析大模型extra bug解决

zhongwei
haungxing 7 months ago
parent
commit
9e4c21749b
  1. 2
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java
  2. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java

2
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FunctionConstants.java

@ -16,7 +16,9 @@ public interface FunctionConstants {
enum TypeEnum { enum TypeEnum {
/**跳转页面**/ /**跳转页面**/
JUMP("1"), JUMP("1"),
/**链接**/
LINK("2"), LINK("2"),
/**参数**/
PARAMS("3") PARAMS("3")
; ;
@Getter @Getter

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java

@ -137,7 +137,9 @@ public class InteractiveServiceImpl implements IInteractiveService {
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
throw new ServiceException("远程调用大模型【获取问题答案】接口失败!"); throw new ServiceException("远程调用大模型【获取问题答案】接口失败!");
}); });
JSONArray.parseArray(response.body(),AnswerVO.class).forEach(answerVO -> {
List<AnswerVO> result = JSONArray.parseArray(response.body(), AnswerVO.class);
result.stream().filter(answerVO -> answerVO.getRunning() == 0).forEach(answerVO -> {
String[] extras = answerVO.getExtra(); String[] extras = answerVO.getExtra();
if(ObjectUtil.isEmpty(answerVO.getExtra()) || extras.length == 0){ if(ObjectUtil.isEmpty(answerVO.getExtra()) || extras.length == 0){
return; return;
@ -145,7 +147,7 @@ public class InteractiveServiceImpl implements IInteractiveService {
List<String> extraList = Arrays.stream(extras).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList()); List<String> extraList = Arrays.stream(extras).map(extraResolveStrategyService::resolve).map(JSON::toJSONString).collect(Collectors.toList());
answerVO.setExtra(extraList.toArray(new String[extraList.size()])); answerVO.setExtra(extraList.toArray(new String[extraList.size()]));
}); });
return JSONArray.parseArray(response.body(),AnswerVO.class); return result;
} }
@Override @Override

Loading…
Cancel
Save