|
@@ -131,7 +131,7 @@ public class GRPCController extends BaseController {
|
|
InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
|
|
InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
|
|
// dataJson = "{\"bot_id\":\"b00001\",\"exp_id\":\"721\",\"norm\":\"" + chatReq.getCategory() + "\",\"feedback\":" + feedback + ",\"simulate\":" + simulate + ",\"session_id\":" + "\"" + sessionId + "\"" + ",\"generate_args\":{\"max_new_tokens\":1024,\"max_length\":4096,\"num_beams\":1,\"do_sample\":true,\"top_p\":0.7,\"temperature\":0.95},\"extra\":{\"rows\":" + rows + "}}";
|
|
// dataJson = "{\"bot_id\":\"b00001\",\"exp_id\":\"721\",\"norm\":\"" + chatReq.getCategory() + "\",\"feedback\":" + feedback + ",\"simulate\":" + simulate + ",\"session_id\":" + "\"" + sessionId + "\"" + ",\"generate_args\":{\"max_new_tokens\":1024,\"max_length\":4096,\"num_beams\":1,\"do_sample\":true,\"top_p\":0.7,\"temperature\":0.95},\"extra\":{\"rows\":" + rows + "}}";
|
|
//2024年6月24日17:59:17 优化,不再拼接JSON字符串
|
|
//2024年6月24日17:59:17 优化,不再拼接JSON字符串
|
|
- dataJson = buildBigModelReqForDecision(chatReq, feedback, simulate, sessionId, decisionReqs, xinyiWarningRecord);
|
|
|
|
|
|
+ dataJson = buildBigModelReqForDecision(chatReq, feedback, simulate, sessionId, decisionReqs, xinyiWarningRecord, chatReq.getTopP(), chatReq.getTemperature());
|
|
log.info("请求大模型的决策的参数为{}", dataJson);
|
|
log.info("请求大模型的决策的参数为{}", dataJson);
|
|
PredictionsRequest request = PredictionsRequest.newBuilder()
|
|
PredictionsRequest request = PredictionsRequest.newBuilder()
|
|
.setModelName("slibra_bot")
|
|
.setModelName("slibra_bot")
|
|
@@ -209,7 +209,7 @@ public class GRPCController extends BaseController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private 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, Double topP, Double temperature) {
|
|
PolicyReq policyReq = new PolicyReq();
|
|
PolicyReq policyReq = new PolicyReq();
|
|
policyReq.setNorm(chatReq.getCategory());
|
|
policyReq.setNorm(chatReq.getCategory());
|
|
policyReq.setFeedback(StringUtils.isBlank(feedback) ? null : JSON.parseObject(feedback, Map.class));
|
|
policyReq.setFeedback(StringUtils.isBlank(feedback) ? null : JSON.parseObject(feedback, Map.class));
|
|
@@ -217,7 +217,8 @@ public class GRPCController extends BaseController {
|
|
policyReq.setSessionId(sessionId);
|
|
policyReq.setSessionId(sessionId);
|
|
//2024年7月5日13:24:10 temperature做区分
|
|
//2024年7月5日13:24:10 temperature做区分
|
|
GenerateArgs generateArgs = new GenerateArgs();
|
|
GenerateArgs generateArgs = new GenerateArgs();
|
|
- generateArgs.setTemperature(bigModelConfig.getTemperature());
|
|
|
|
|
|
+ generateArgs.setTemperature(Objects.isNull(temperature) ? bigModelConfig.getTemperature() : temperature);
|
|
|
|
+ generateArgs.setTopP(Objects.isNull(topP) ? bigModelConfig.getTopP() : topP);
|
|
policyReq.setGenerateArgs(generateArgs);
|
|
policyReq.setGenerateArgs(generateArgs);
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
map.put("rows", decisionReqs);
|
|
map.put("rows", decisionReqs);
|
|
@@ -422,7 +423,7 @@ public class GRPCController extends BaseController {
|
|
InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
|
|
InferenceAPIsServiceGrpc.InferenceAPIsServiceBlockingStub stub = InferenceAPIsServiceGrpc.newBlockingStub(channel);
|
|
// String dataJson = "{\"bot_id\":\"721\",\"exp_id\":\"721\",\"session_id\":\"" + sessionId + "\",\"use_rag\":\"true\",\"prompt\":\"你是LibraAI水务大模型,由红杉天枰开发的水务垂直大语言模型,能够提供水务行业专家问答、智能决策、报表分析、智能工单管理等一系列功能,作为水务人的AI助手,你会竭尽全力帮助我处理工作问题。\",\"history_dia\":" + JSON.toJSONString(historyDates) + ",\"generate_args\":{\"max_new_tokens\":2048,\"max_length\":4096,\"num_beams\":1,\"do_sample\":true,\"top_p\":0.7,\"temperature\":0.95},\"extra\":{ \"ip_address\": \"" + ipAddr + "\" },\"strengthen\":" + (isStrong == 1) + "}";
|
|
// String dataJson = "{\"bot_id\":\"721\",\"exp_id\":\"721\",\"session_id\":\"" + sessionId + "\",\"use_rag\":\"true\",\"prompt\":\"你是LibraAI水务大模型,由红杉天枰开发的水务垂直大语言模型,能够提供水务行业专家问答、智能决策、报表分析、智能工单管理等一系列功能,作为水务人的AI助手,你会竭尽全力帮助我处理工作问题。\",\"history_dia\":" + JSON.toJSONString(historyDates) + ",\"generate_args\":{\"max_new_tokens\":2048,\"max_length\":4096,\"num_beams\":1,\"do_sample\":true,\"top_p\":0.7,\"temperature\":0.95},\"extra\":{ \"ip_address\": \"" + ipAddr + "\" },\"strengthen\":" + (isStrong == 1) + "}";
|
|
//2024年6月25日18:12:23 优化,不再使用拼接JSON字符串
|
|
//2024年6月25日18:12:23 优化,不再使用拼接JSON字符串
|
|
- String dataJson = buildBigModelReqForChat(sessionId, historyDates, ipAddr, isStrong);
|
|
|
|
|
|
+ String dataJson = buildBigModelReqForChat(sessionId, historyDates, ipAddr, isStrong, chatReq.getTopP(), chatReq.getTemperature());
|
|
log.info("请求大模型的问答参数为{}", dataJson);
|
|
log.info("请求大模型的问答参数为{}", dataJson);
|
|
PredictionsRequest request = PredictionsRequest.newBuilder()
|
|
PredictionsRequest request = PredictionsRequest.newBuilder()
|
|
.setModelName("slibra_bot")
|
|
.setModelName("slibra_bot")
|
|
@@ -478,13 +479,14 @@ public class GRPCController extends BaseController {
|
|
// return AjaxResult.success("ok");
|
|
// return AjaxResult.success("ok");
|
|
}
|
|
}
|
|
|
|
|
|
- private String buildBigModelReqForChat(String sessionId, List<String> historyDates, String ipAddr, int isStrong) {
|
|
|
|
|
|
+ private String buildBigModelReqForChat(String sessionId, List<String> historyDates, String ipAddr, int isStrong, Double topP, Double temperature) {
|
|
ChatRequest chatRequest = new ChatRequest();
|
|
ChatRequest chatRequest = new ChatRequest();
|
|
chatRequest.setSessionId(sessionId);
|
|
chatRequest.setSessionId(sessionId);
|
|
chatRequest.setHistoryDia(historyDates);
|
|
chatRequest.setHistoryDia(historyDates);
|
|
//2024年7月5日13:24:10 temperature做区分
|
|
//2024年7月5日13:24:10 temperature做区分
|
|
GenerateArgs generateArgs = new GenerateArgs();
|
|
GenerateArgs generateArgs = new GenerateArgs();
|
|
- generateArgs.setTemperature(bigModelConfig.getTemperature());
|
|
|
|
|
|
+ generateArgs.setTemperature(Objects.isNull(temperature) ? bigModelConfig.getTemperature() : temperature);
|
|
|
|
+ generateArgs.setTopP(Objects.isNull(topP) ? bigModelConfig.getTopP() : topP);
|
|
chatRequest.setGenerateArgs(generateArgs);
|
|
chatRequest.setGenerateArgs(generateArgs);
|
|
Map<String, Object> extra = new HashMap<>();
|
|
Map<String, Object> extra = new HashMap<>();
|
|
extra.put("ip_address", ipAddr);
|
|
extra.put("ip_address", ipAddr);
|