Просмотр исходного кода

调用大模型区分环境 ip 端口 temperature

wangmiaomiao 9 месяцев назад
Родитель
Сommit
d4bfbd6008

+ 16 - 4
slibra-admin/src/main/java/com/slibra/web/controller/business/GRPCController.java

@@ -10,6 +10,7 @@ import com.slibra.business.req.*;
 import com.slibra.business.res.WorkOrderRes;
 import com.slibra.business.service.IFrontService;
 import com.slibra.common.DecimalUtils;
+import com.slibra.common.config.BigModelConfig;
 import com.slibra.common.core.controller.BaseController;
 import com.slibra.common.enums.BusinessEnum;
 import com.slibra.common.exception.ServiceException;
@@ -69,6 +70,9 @@ public class GRPCController extends BaseController {
     @Autowired
     private TXinyiNormConfigMapper xinyiNormConfigMapper;
 
+    @Autowired
+    private BigModelConfig bigModelConfig;
+
 
 
     /**
@@ -121,7 +125,7 @@ public class GRPCController extends BaseController {
         boolean needAdd = true;//标识变量是否可以保存
         String dataJson = "";
         try {
-            channel = ManagedChannelBuilder.forAddress("10.0.0.24", 17070)
+            channel = ManagedChannelBuilder.forAddress(bigModelConfig.getIp(), bigModelConfig.getPort())
                     .usePlaintext()
                     .build();
             InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
@@ -205,12 +209,16 @@ public class GRPCController extends BaseController {
         }
     }
 
-    private static String buildBigModelReqForDecision(ChatReq chatReq, String feedback, String simulate, String sessionId, List<DecisionReq> decisionReqs, TXinyiWarningRecord xinyiWarningRecord) {
+    private String buildBigModelReqForDecision(ChatReq chatReq, String feedback, String simulate, String sessionId, List<DecisionReq> decisionReqs, TXinyiWarningRecord xinyiWarningRecord) {
         PolicyReq policyReq = new PolicyReq();
         policyReq.setNorm(chatReq.getCategory());
         policyReq.setFeedback(StringUtils.isBlank(feedback) ? null : JSON.parseObject(feedback, Map.class));
         policyReq.setSimulate(StringUtils.isBlank(simulate) ? null : JSON.parseObject(simulate, Map.class));
         policyReq.setSessionId(sessionId);
+        //2024年7月5日13:24:10 temperature做区分
+        GenerateArgs generateArgs = new GenerateArgs();
+        generateArgs.setTemperature(bigModelConfig.getTemperature());
+        policyReq.setGenerateArgs(generateArgs);
         HashMap<String, Object> map = new HashMap<>();
         map.put("rows", decisionReqs);
         //2024年6月25日14:16:05 增加报警是管控值报警还是标准值报警
@@ -408,7 +416,7 @@ public class GRPCController extends BaseController {
         //将新的问题放入集合中
         historyDates.add(chatReq.getQuestion());
         try {
-            channel = ManagedChannelBuilder.forAddress("10.0.0.24", 17070)
+            channel = ManagedChannelBuilder.forAddress(bigModelConfig.getIp(), bigModelConfig.getPort())
                     .usePlaintext()
                     .build();
             InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
@@ -470,10 +478,14 @@ public class GRPCController extends BaseController {
 //        return AjaxResult.success("ok");
     }
 
-    private static String buildBigModelReqForChat(String sessionId, List<String> historyDates, String ipAddr, int isStrong) {
+    private String buildBigModelReqForChat(String sessionId, List<String> historyDates, String ipAddr, int isStrong) {
         ChatRequest chatRequest = new ChatRequest();
         chatRequest.setSessionId(sessionId);
         chatRequest.setHistoryDia(historyDates);
+        //2024年7月5日13:24:10 temperature做区分
+        GenerateArgs generateArgs = new GenerateArgs();
+        generateArgs.setTemperature(bigModelConfig.getTemperature());
+        chatRequest.setGenerateArgs(generateArgs);
         Map<String, Object> extra = new HashMap<>();
         extra.put("ip_address", ipAddr);
         chatRequest.setExtra(extra);

+ 8 - 1
slibra-admin/src/main/resources/application-dev.yml

@@ -81,4 +81,11 @@ application:
     deposit: 0.01
     wechatPay:
         orderNotifyUrl: https://beta.fuxicarbon.com/api/wechat-pay-records/orderNotify
-        depositNotifyUrl: https://beta.fuxicarbon.com/api/wechat-pay-records/depositNotify
+        depositNotifyUrl: https://beta.fuxicarbon.com/api/wechat-pay-records/depositNotify
+
+
+#默认走测试环境
+big-model:
+  ip: 10.0.0.24
+  port: 27070
+  temperature: 0.7

+ 8 - 1
slibra-admin/src/main/resources/application-local.yml

@@ -103,4 +103,11 @@ oss:
         url: https://static.fuxicarbon.com #域名
         accessKey: z7EU9DhXbF9Y0J462Qmo8a8HvCOu5KUhR3PiGN-9 #
         secretKey: t6LGwyfl4gFbckQtyk2QUYW1162u5e7oZh9Ixsnd #
-        bucketName: fuxicarbon  #空间名
+        bucketName: fuxicarbon  #空间名
+
+
+#默认走测试环境
+big-model:
+  ip: 10.0.0.24
+  port: 27070
+  temperature: 0.7

+ 8 - 1
slibra-admin/src/main/resources/application-prod.yml

@@ -81,4 +81,11 @@ application:
     deposit: 0.01
     wechatPay:
         orderNotifyUrl: https://beta.fuxicarbon.com/api/wechat-pay-records/orderNotify
-        depositNotifyUrl: https://beta.fuxicarbon.com/api/wechat-pay-records/depositNotify
+        depositNotifyUrl: https://beta.fuxicarbon.com/api/wechat-pay-records/depositNotify
+
+
+#生产环境配置
+big-model:
+  ip: 10.0.0.24
+  port: 17070
+  temperature: 0.95

+ 6 - 0
slibra-admin/src/main/resources/application.yml

@@ -228,3 +228,9 @@ oss:
     accessKey: z7EU9DhXbF9Y0J462Qmo8a8HvCOu5KUhR3PiGN-9 #
     secretKey: t6LGwyfl4gFbckQtyk2QUYW1162u5e7oZh9Ixsnd #
     bucketName: fuxicarbon  #空间名
+
+#默认走测试环境
+big-model:
+  ip: 10.0.0.24
+  port: 27070
+  temperature: 0.7

+ 30 - 0
slibra-common/src/main/java/com/slibra/common/config/BigModelConfig.java

@@ -0,0 +1,30 @@
+package com.slibra.common.config;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * 读取项目相关配置
+ * 
+ *
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Component
+@ConfigurationProperties(prefix = "big-model")
+public class BigModelConfig
+{
+
+    private String ip;
+
+    private int port;
+
+    private Double temperature;
+
+
+}

+ 16 - 7
slibra-quartz/src/main/java/com/slibra/quartz/task/AsyncTask.java

@@ -6,13 +6,11 @@ import com.alibaba.fastjson2.JSONWriter;
 import com.google.protobuf.ByteString;
 import com.slibra.business.domain.*;
 import com.slibra.business.mapper.*;
-import com.slibra.business.req.ChatReq;
-import com.slibra.business.req.ChatRequest;
-import com.slibra.business.req.DecisionReq;
-import com.slibra.business.req.PolicyReq;
+import com.slibra.business.req.*;
 import com.slibra.business.res.ShowValueCSBasic;
 import com.slibra.business.res.ShowValueJSBasic;
 import com.slibra.common.DecimalUtils;
+import com.slibra.common.config.BigModelConfig;
 import com.slibra.common.constant.MyConstants;
 import com.slibra.common.enums.BusinessEnum;
 import com.slibra.common.utils.DateUtils;
@@ -69,6 +67,9 @@ public class AsyncTask {
     @Autowired
     private TXinyiBigTableHourMapper xinyiBigTableHourMapper;
 
+    @Autowired
+    private BigModelConfig bigModelConfig;
+
 
     /**
      *
@@ -914,7 +915,7 @@ public class AsyncTask {
         // 获取输出流
         ManagedChannel channel = null;
         try {
-            channel = ManagedChannelBuilder.forAddress("10.0.0.24", 17070)
+            channel = ManagedChannelBuilder.forAddress(bigModelConfig.getIp(), bigModelConfig.getPort())
                     .usePlaintext()
                     .build();
             InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
@@ -962,10 +963,14 @@ public class AsyncTask {
     }
 
 
-    private static String buildBigModelReqForChat(String sessionId, List<String> historyDates, String ipAddr, Boolean strengthen) {
+    private String buildBigModelReqForChat(String sessionId, List<String> historyDates, String ipAddr, Boolean strengthen) {
         ChatRequest chatRequest = new ChatRequest();
         chatRequest.setSessionId(sessionId);
         chatRequest.setHistoryDia(historyDates);
+        //2024年7月5日13:24:10 temperature做区分
+        GenerateArgs generateArgs = new GenerateArgs();
+        generateArgs.setTemperature(bigModelConfig.getTemperature());
+        chatRequest.setGenerateArgs(generateArgs);
         Map<String, Object> extra = new HashMap<>();
         extra.put("ip_address", ipAddr);
         chatRequest.setExtra(extra);
@@ -1057,7 +1062,7 @@ public class AsyncTask {
         ManagedChannel channel = null;
         String dataJson = "";
         try {
-            channel = ManagedChannelBuilder.forAddress("10.0.0.24", 17070)
+            channel = ManagedChannelBuilder.forAddress(bigModelConfig.getIp(), bigModelConfig.getPort())
                     .usePlaintext()
                     .build();
             InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
@@ -1069,6 +1074,10 @@ public class AsyncTask {
             policyReq.setFeedback(hashMap);//不能传null
             policyReq.setSimulate(hashMap);//不能传null
             policyReq.setSessionId(sessionId);
+            //2024年7月5日13:24:10 temperature做区分
+            GenerateArgs generateArgs = new GenerateArgs();
+            generateArgs.setTemperature(bigModelConfig.getTemperature());
+            policyReq.setGenerateArgs(generateArgs);
             HashMap<String, Object> map = new HashMap<>();
             map.put("rows", decisionReqs);
             //2024年6月25日14:16:05 增加报警是管控值报警还是标准值报警

+ 14 - 6
slibra-quartz/src/main/java/com/slibra/quartz/task/RyTask.java

@@ -12,11 +12,13 @@ import com.slibra.business.domain.*;
 import com.slibra.business.mapper.*;
 import com.slibra.business.req.ChatReq;
 import com.slibra.business.req.ChatRequest;
+import com.slibra.business.req.GenerateArgs;
 import com.slibra.business.req.PredictorRequest;
 import com.slibra.business.res.ChartBasic;
 import com.slibra.business.res.ShowValueChartBasic;
 import com.slibra.business.service.ITXinyiForecastComparisonService;
 import com.slibra.common.DecimalUtils;
+import com.slibra.common.config.BigModelConfig;
 import com.slibra.common.constant.MyConstants;
 import com.slibra.common.enums.BusinessEnum;
 import com.slibra.common.enums.DataSourceType;
@@ -95,6 +97,9 @@ public class RyTask
     @Autowired
     private ITXinyiForecastComparisonService xinyiForecastComparisonService;
 
+    @Autowired
+    private BigModelConfig bigModelConfig;
+
 
 //    public final static StopWatch watch = new StopWatch("task");
     public static final String[] queryTags = {"信义污水厂JS_COD_Value","信义污水厂JS_PH_Value","信义污水厂JS_SS_Value","信义污水厂JS_ZL_Value","信义污水厂JS_ZA_Value","信义污水厂JS_AD_Value","信义污水厂JS_T_Value","信义污水厂进水泵房液位","信义污水厂出水瞬时流量","信义污水厂升级出水COD","信义污水厂升级出水PH","信义污水厂升级出水SS","信义污水厂升级出水TN","信义污水厂升级出水TP","信义污水厂升级出水氨氮","信义污水厂AIT202_Value","信义污水厂AIT203_Value","信义污水厂AIT207_Value","信义污水厂AIT206_Value","信义污水厂AIT209_Value","信义污水厂AIT210_Value","信义污水厂进水TDS","信义污水厂FT101_Value","信义污水厂SWCHHYHLB1_R_Value","信义污水厂SWCHHYHLB2_R_Value","信义污水厂SWCHHYHLB3_R_Value","信义污水厂SWCHHYHLB4_R_Value","信义污水厂SWCHHYHLB5_R_Value","信义污水厂SWCHHYHLB6_R_Value","信义污水厂SWCWNHLB1_R_Value","信义污水厂SWCWNHLB2_R_Value","信义污水厂SWCWNHLB3_R_Value","信义污水厂SWCWNHLB4_R_Value","信义污水厂SWCWNHLB5_R_Value","信义污水厂GFJ1_R_Value","信义污水厂GFJ2_R_Value","信义污水厂GFJ3_R_Value","信义污水厂GFJ4_R_Value","信义污水厂GFJ5_R_Value","信义污水厂GFJ6_R_Value","信义污水厂GFJ1_KQLL_Value","信义污水厂GFJ2_KQLL_Value","信义污水厂GFJ3_KQLL_Value","信义污水厂GFJ4_KQLL_Value","信义污水厂GFJ5_KQLL_Value","信义污水厂GFJ6_KQLL_Value","信义污水厂实际碳源加药量","信义污水厂除磷加药瞬时流量", "信义污水厂_除磷P04预测值_"};
@@ -1236,7 +1241,7 @@ public class RyTask
         // 获取输出流
         ManagedChannel channel = null;
         try {
-            channel = ManagedChannelBuilder.forAddress("10.0.0.24", 17070)
+            channel = ManagedChannelBuilder.forAddress(bigModelConfig.getIp(), bigModelConfig.getPort())
                     .usePlaintext()
                     .build();
             InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
@@ -1283,10 +1288,14 @@ public class RyTask
         }
     }
 
-    private static String buildBigModelReqForChat(String sessionId, List<String> historyDates) {
+    private String buildBigModelReqForChat(String sessionId, List<String> historyDates) {
         ChatRequest chatRequest = new ChatRequest();
         chatRequest.setSessionId(sessionId);
         chatRequest.setHistoryDia(historyDates);
+        //2024年7月5日13:24:10 temperature做区分
+        GenerateArgs generateArgs = new GenerateArgs();
+        generateArgs.setTemperature(bigModelConfig.getTemperature());
+        chatRequest.setGenerateArgs(generateArgs);
         Map<String, Object> extra = new HashMap<>();
 //        extra.put("ip_address", IpUtils.getIpAddr());
         extra.put("ip_address", null);
@@ -1296,11 +1305,11 @@ public class RyTask
     }
 
 
-    public static String getPredictor(String type){
+    public String getPredictor(String type){
         // 获取输出流
         ManagedChannel channel = null;
         try {
-            channel = ManagedChannelBuilder.forAddress("10.0.0.24", 17070)
+            channel = ManagedChannelBuilder.forAddress(bigModelConfig.getIp(), bigModelConfig.getPort())
                     .usePlaintext()
                     .build();
             InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
@@ -1367,7 +1376,7 @@ public class RyTask
         // 获取输出流
         ManagedChannel channel = null;
         try {
-            channel = ManagedChannelBuilder.forAddress("10.0.0.24", 17070)
+            channel = ManagedChannelBuilder.forAddress(bigModelConfig.getIp(), bigModelConfig.getPort())
                     .usePlaintext()
                     .build();
             InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
@@ -1416,7 +1425,6 @@ public class RyTask
     }
 
     /**
-     * @see  buildShortReportQueryDataNew
      * @param dailyTwoRecords
      * @return
      */