|
|
@@ -135,6 +135,16 @@ public class AIEvaluationService {
|
|
|
this.evaluationMapperServiceImpl = evaluationMapperServiceImpl;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 一键双评
|
|
|
+ * @param assignmentId
|
|
|
+ * @param studentId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public AIEntry evaluateAll(Long assignmentId, Long studentId) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public CompletableFuture<AIEntry> evaluationAsync(Long assignmentId, Long studentId) {
|
|
|
return CompletableFuture.supplyAsync(() -> evaluation(assignmentId, studentId), aiTaskExecutor);
|
|
|
}
|
|
|
@@ -254,8 +264,7 @@ public class AIEvaluationService {
|
|
|
}
|
|
|
|
|
|
String content = engagement.getTextContent();
|
|
|
- // TODO: 句子分割需要详细考虑和判断
|
|
|
- String[] sentences = content.split("\\.");
|
|
|
+ String[] sentences = getSentenceList(content);
|
|
|
List<SentenceEvaluation> sentenceEvaluationsList = new ArrayList<>();
|
|
|
CompletableFuture<?>[] futures = new CompletableFuture[sentences.length];
|
|
|
|
|
|
@@ -298,6 +307,11 @@ public class AIEvaluationService {
|
|
|
return sentenceEvaluationsList;
|
|
|
}
|
|
|
|
|
|
+ private static String[] getSentenceList(String content) {
|
|
|
+ String[] sentences = content.split("\\.");
|
|
|
+ return sentences;
|
|
|
+ }
|
|
|
+
|
|
|
private SentenceEvaluation processSingleSentenceWithRetry(Long assignmentId, Long studentId, String content, String description, String sentence, int sentenceNo, int version) {
|
|
|
int retryTime = 0;
|
|
|
while (retryTime < RETRY_COUNT) {
|
|
|
@@ -311,6 +325,18 @@ public class AIEvaluationService {
|
|
|
return new SentenceEvaluation().setVersion(version).setNo(sentenceNo + 1).setType("error").setCategory("error").setEvaluation("error").setStudentId(studentId).setAssignmentId(assignmentId);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 向Dify发起请求智评单个句子
|
|
|
+ * @param assignmentId
|
|
|
+ * @param studentId
|
|
|
+ * @param content
|
|
|
+ * @param assignmentDesc
|
|
|
+ * @param sentence
|
|
|
+ * @param sentenceNo
|
|
|
+ * @param version
|
|
|
+ * @param retryCount
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private SentenceEvaluation processSingleSentence(
|
|
|
Long assignmentId, Long studentId,
|
|
|
String content, String assignmentDesc,
|
|
|
@@ -389,4 +415,30 @@ public class AIEvaluationService {
|
|
|
return evaluationMapper.selectList(queryWrapper);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 对某一个句子进行智评
|
|
|
+ * @param assignmentId
|
|
|
+ * @param studentId
|
|
|
+ * @param version
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public SentenceEvaluation evaluateSentenceByOne(Long assignmentId, Long studentId, Integer version, Integer sentenceNo) {
|
|
|
+ Engagement engagement = studentAssignmentMapper.findEngagementByStudentIdAndAssignmentId(studentId, assignmentId);
|
|
|
+ if(engagement == null) throw MyException.create(HttpStatus.BAD_REQUEST, "作业参与不存在");
|
|
|
+ Assignment assignment = assignmentMapper.selectById(assignmentId);
|
|
|
+ if (assignment == null) throw MyException.create(HttpStatus.BAD_REQUEST, "作业不存在");
|
|
|
+ Evaluation evaluationJudge = evaluationMapperServiceImpl.getByVersion(assignmentId, studentId, engagement.getVersion());
|
|
|
+ if(evaluationJudge == null) throw MyException.create(HttpStatus.BAD_REQUEST, "没有该版本的智评记录");
|
|
|
+
|
|
|
+ String content = engagement.getTextContent();
|
|
|
+ String[] sentences = getSentenceList(content);
|
|
|
+ SentenceEvaluation result = processSingleSentenceWithRetry(assignmentId, studentId, content, assignment.getDescription(), sentences[sentenceNo], sentenceNo, engagement.getVersion());
|
|
|
+ if(result == null || result.getType().equals("error")) {
|
|
|
+ throw MyException.create(HttpStatus.BAD_REQUEST, "智评失败,请重试");
|
|
|
+ }
|
|
|
+
|
|
|
+ sentenceEvaluationMapperServiceImpl.saveOrUpdateByCondition(result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|