From 11fd53b911662e5d8b40d95371a432def4fa1e06 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 12 Jun 2024 16:33:42 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E6=96=B0=E5=A2=9E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=83=AD=E7=82=B9=E9=97=AE=E9=A2=98=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/configuration/BigModelInvokeUrl.java | 2 ++ .../controller/InteractiveController.java | 16 +++++++++++++++ .../interactive/service/IInteractiveService.java | 6 ++++++ .../service/impl/InteractiveServiceImpl.java | 24 ++++++++++++++++++++++ .../hzims/bigmodel/interactive/vo/AnswerVO.java | 9 +++++++- 5 files changed, 56 insertions(+), 1 deletion(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java index 8179cba..996a155 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/configuration/BigModelInvokeUrl.java @@ -28,4 +28,6 @@ public class BigModelInvokeUrl { private String updateCanvas; private String assistantKnowledgeAsk; + + private String hotQuestion; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index c109e57..26edbdf 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -2,6 +2,7 @@ package com.hnac.hzims.bigmodel.interactive.controller; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.google.common.collect.Lists; import com.hnac.hzims.bigmodel.BigModelConstants; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; @@ -16,6 +17,7 @@ import org.springblade.system.dto.ControlDTO; import org.springframework.web.bind.annotation.*; import java.text.DecimalFormat; +import java.util.List; /** * @Author: huangxing @@ -92,4 +94,18 @@ public class InteractiveController { DecimalFormat format = new DecimalFormat("0.00"); return R.data(format.format(generate) + "kWh"); } + + @ApiOperation("获取热点问题") + @ApiOperationSupport(order = 8) + @GetMapping("/hotQuestions") + public R hotQuestions() { + try{ + List questions = interactiveService.hotQuestions(); + return R.data(questions); + } + catch (Exception e) { + e.printStackTrace(); + return R.data(Lists.newArrayList()); + } + } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java index c6433df..9474795 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java @@ -48,4 +48,10 @@ public interface IInteractiveService { R sendRemoteControl(ControlDTO operate); Double generation(String stationId, String startTime, String endTime); + + /** + * 获取热点问题 + * @return 热点问题 + */ + List hotQuestions(); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index 2fd2480..d670ef6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -37,6 +37,7 @@ import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; +import org.apache.poi.ss.formula.functions.T; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.tool.api.R; @@ -196,6 +197,29 @@ public class InteractiveServiceImpl implements IInteractiveService { } @Override + public List hotQuestions() { + String url = fdpHost + bigModelInvokeUrl.getHotQuestion(); + return this.postCall(url,null,List.class); + } + + /** + * 远程调用http接口 + * @param url 接口url + * @param body 传参 + * @param resultT 结果解析对象 + * @return 结果 + * @param 结果解析对象类型 + */ + public T postCall(String url,Map body,Class resultT) { + HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { + log.error("远程调用大模型接口" + url + "失败!"); + throw new ServiceException("远程调用大模型接口" + url + "失败!"); + }); + return JSONObject.parseObject(response.body(),resultT); + } + + @Override public void updateVideo(Map request) { HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getUpdateVideo()) .body(JSON.toJSONString(request)).execute(); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java index 47908f1..29baf54 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java @@ -48,9 +48,16 @@ public class AnswerVO implements Serializable { @ApiModelProperty("其它调用的参数") private Object[] extras; + @ApiModelProperty("用于语音回复的状态文本") + @JSONField(name = "voice_text") + private String[] voiceText; + + @ApiModelProperty("用于语音回复的答案") + @JSONField(name = "voice_answer") + private String[] voiceAnswer; + public static void error(AnswerVO usualVO) { usualVO.setRunning(0); usualVO.setStatus(-2); } - }