Przeglądaj źródła

专家问答允许用户自定义prompt

王苗苗 7 miesięcy temu
rodzic
commit
9c75aeba1c

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

@@ -608,7 +608,7 @@ public class GRPCController extends BaseController {
 //                else
 //                    tools = tools;
 //            }
-            String dataJson = buildBigModelReqForChat(sessionId, historyDates, ipAddr, isStrong, chatReq.getTopP(), chatReq.getTemperature(), tools, useRag, extraStr);
+            String dataJson = buildBigModelReqForChat(sessionId, historyDates, ipAddr, isStrong, chatReq.getTopP(), chatReq.getTemperature(), tools, useRag, extraStr, chatReq.getPrompt());
             log.info("******请求大模型的问答参数为{}", dataJson);
             PredictionsRequest request = PredictionsRequest.newBuilder()
                     .setModelName("slibra_bot")
@@ -796,7 +796,7 @@ public class GRPCController extends BaseController {
         return JSON.toJSONString(map);
     }
 
-    private String buildBigModelReqForChat(String sessionId, List<String> historyDates, String ipAddr, int isStrong, Double topP, Double temperature, String tools, boolean useRag, String extraStr) {
+    private String buildBigModelReqForChat(String sessionId, List<String> historyDates, String ipAddr, int isStrong, Double topP, Double temperature, String tools, boolean useRag, String extraStr, String prompt) {
         ChatRequest chatRequest = new ChatRequest();
         chatRequest.setSessionId(sessionId);
         chatRequest.setHistoryDia(historyDates);
@@ -813,7 +813,8 @@ public class GRPCController extends BaseController {
         chatRequest.setStrengthen(isStrong == 1);
         chatRequest.setTools(tools);
         chatRequest.setUseRag(useRag);
-        chatRequest.setPrompt(ZJWD_PROMPT);
+        //2024年08月11日16:04:21 允许用户自定义prompt
+        chatRequest.setPrompt(StringUtils.isBlank(prompt) ? DEFAULT_PROMPT : prompt);
         return JSON.toJSONString(chatRequest);
     }
 

+ 3 - 0
slibra-common/src/main/java/com/slibra/common/constant/MyConstants.java

@@ -338,6 +338,9 @@ public class MyConstants {
             "即使用户的输入模糊或未指定要求,也请保持上述格式。";
 
 
+    public static final String DEFAULT_PROMPT = "你是LibraAI水务大模型,由红杉天枰开发的水务垂直大语言模型,能够提供水务行业专家问答、智能决策、报表分析、智能工单管理等一系列功能,作为水务人的AI助手,你会竭尽全力帮助我处理工作问题。";
+
+
     public static void main(String[] args) {
         System.out.println(DecimalUtils.getAbsAndScale(new BigDecimal("2.211"), MyConstants.INT_0));
         System.out.println(DecimalUtils.getAbsAndScaleStr("2.211", MyConstants.INT_0));

+ 12 - 0
slibra-system/src/main/java/com/slibra/business/req/ChatReq.java

@@ -117,6 +117,18 @@ public class ChatReq extends TXinyiChatRecord {
     //2024年7月27日18:12:45 新增参数
     private String tools;
 
+
+    //2024年08月11日16:01:27 允许用户自定义prompt
+    private String prompt;
+
+    public String getPrompt() {
+        return prompt;
+    }
+
+    public void setPrompt(String prompt) {
+        this.prompt = prompt;
+    }
+
     public String getTools() {
         return tools;
     }