Commit b7ab069d authored by 陈立彬's avatar 陈立彬

dify agent调用字段

parent bd2da345
...@@ -46,6 +46,7 @@ public class AiPlatformExtensionService { ...@@ -46,6 +46,7 @@ public class AiPlatformExtensionService {
inputs.put("scene", "single_evaluate"); inputs.put("scene", "single_evaluate");
inputs.put("question", question); inputs.put("question", question);
inputs.put("answer", answer); inputs.put("answer", answer);
inputs.put("user_answer", userAnswer);
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("query", userAnswer); param.put("query", userAnswer);
param.put("inputs", inputs); param.put("inputs", inputs);
...@@ -83,16 +84,14 @@ public class AiPlatformExtensionService { ...@@ -83,16 +84,14 @@ public class AiPlatformExtensionService {
* 考试总点评 * 考试总点评
* @param sessionId * @param sessionId
* @param userId * @param userId
* @param avgScore * @param businessNo
* @param qaResultList
*/ */
public String run4TotalEvaluate(String sessionId, String userId, Float avgScore, String qaResultList) { public String run4TotalEvaluate(String sessionId, String userId, String businessNo) {
Map<String, Object> inputs = new HashMap<>(); Map<String, Object> inputs = new HashMap<>();
inputs.put("scene", "total_evaluate"); inputs.put("scene", "total_evaluate");
inputs.put("avg_score", avgScore); inputs.put("business_no", businessNo);
inputs.put("qa_result_list", qaResultList);
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("query", "Not_Null"); param.put("query", businessNo);
param.put("inputs", inputs); param.put("inputs", inputs);
param.put("response_mode", "blocking"); param.put("response_mode", "blocking");
param.put("conversation_id", ""); param.put("conversation_id", "");
......
...@@ -1287,6 +1287,21 @@ public class AppExamineService { ...@@ -1287,6 +1287,21 @@ public class AppExamineService {
return null; return null;
} }
/**
* 获取考试详情
* @param businessNo 考试流水号
* @return
*/
public ExamineRecordMobileDto getExamineRecordDetail(String businessNo) {
// 获取考试记录信息
ExamineRecordResponseModel recordModel = examineService.examineRecordDetail(businessNo);
if(Objects.nonNull(recordModel)) {
Integer recordId = recordModel.getId();
return this.examineRecordMobileDetail(recordId);
}
return null;
}
/** /**
* 退出考试,清除考试记录 * 退出考试,清除考试记录
* @param userPrincipal * @param userPrincipal
......
...@@ -43,7 +43,7 @@ public class AiPlatformExtensionController { ...@@ -43,7 +43,7 @@ public class AiPlatformExtensionController {
String userId = UUID.randomUUID().toString(); String userId = UUID.randomUUID().toString();
String sessionId = UUID.randomUUID().toString(); String sessionId = UUID.randomUUID().toString();
extensionService.run4TotalEvaluate(sessionId, userId, null, null); extensionService.run4TotalEvaluate(sessionId, userId, null);
return ApiResponse.ok("SUCCESS"); return ApiResponse.ok("SUCCESS");
} }
} }
...@@ -72,6 +72,13 @@ public class ExamineMobileController { ...@@ -72,6 +72,13 @@ public class ExamineMobileController {
return ApiResponse.ok(detail); return ApiResponse.ok(detail);
} }
@Operation(summary = "获取对练记录详情")
@GetMapping("/record/detail")
public ApiResponse<ExamineRecordMobileDto> recordDetail(@Schema(description = "对练流水号") @RequestParam("business_no") String businessNo) {
ExamineRecordMobileDto detail = examineService.getExamineRecordDetail(businessNo);
return ApiResponse.ok(detail);
}
@Operation(summary = "开始考试,并返回考试流水号&第一道题目") @Operation(summary = "开始考试,并返回考试流水号&第一道题目")
@PostMapping(value = "/start_examine") @PostMapping(value = "/start_examine")
public ApiResponse<ExamineStartResultDto> startExamine(@Parameter(hidden = true) UserPrincipal userPrincipal, public ApiResponse<ExamineStartResultDto> startExamine(@Parameter(hidden = true) UserPrincipal userPrincipal,
......
...@@ -112,23 +112,8 @@ public class SingleJob extends QuartzJobBean { ...@@ -112,23 +112,8 @@ public class SingleJob extends QuartzJobBean {
double totalScore = detailRecordList.stream().filter(v -> Objects.nonNull(v.getScore())).mapToDouble(ExamineDetailRecordResponseModel::getScore).sum(); double totalScore = detailRecordList.stream().filter(v -> Objects.nonNull(v.getScore())).mapToDouble(ExamineDetailRecordResponseModel::getScore).sum();
Double avgScore = totalScore / detailRecordList.size(); Double avgScore = totalScore / detailRecordList.size();
List<Integer> qaIdList = detailRecordList.stream().map(ExamineDetailRecordResponseModel::getQaId).collect(Collectors.toList());
List<ExamineQaResponseModel> examineQaList = examineService.examineQaList(qaIdList);
Map<Integer, ExamineQaResponseModel> qaMap = examineQaList.stream().collect(toMap(ExamineQaResponseModel::getId, Function.identity()));
String qaResultStr = "";
for(int i = 0; i < detailRecordList.size(); i++) {
ExamineDetailRecordResponseModel detail = detailRecordList.get(i);
ExamineQaResponseModel qa = qaMap.get(detail.getQaId());
qaResultStr += "问题 " + (i + 1) + ": " + qa.getQuestion() + "\n";
qaResultStr += "得分:" + detail.getScore() + "\n";
qaResultStr += "评分说明:" + detail.getEvaluation() + "\n";
qaResultStr += "----------------------------------------\n";
}
// 执行综合点评 // 执行综合点评
String overallEvaluation = extensionService.run4TotalEvaluate(businessNo, job.getUserId(), avgScore.floatValue(), qaResultStr); String overallEvaluation = extensionService.run4TotalEvaluate(businessNo, job.getUserId(), businessNo);
if(StrUtil.isNotEmpty(overallEvaluation)) { if(StrUtil.isNotEmpty(overallEvaluation)) {
// 更新 // 更新
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment