diff --git a/src/main/java/cn/teammodel/controller/frontend/AiController.java b/src/main/java/cn/teammodel/controller/frontend/AiController.java index 4f9b6b0..dae9a17 100644 --- a/src/main/java/cn/teammodel/controller/frontend/AiController.java +++ b/src/main/java/cn/teammodel/controller/frontend/AiController.java @@ -151,14 +151,6 @@ public class AiController { @PostMapping("chat/comments") @ApiOperation("设置评语") public SseEmitter chatComments(@RequestBody @Valid ChatCommentsDto chatCommentsDto) { - /* - Authentication user0 = SecurityUtil.getAuthentication(); - Object user01 = SecurityUtil.getAuthentication().getPrincipal(); - TmdUserDetail user02 = (TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal(); - Claims user03 = ((TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal()).getClaims(); - String user04 = ((TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal()).getClaims().getSubject(); - */ - //String userId = ((TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal()).getClaims().getSubject(); // 获取getClaims时为空 String userId = ((TmdUserDetail) SecurityUtil.getAuthentication().getPrincipal()).getUser().getId(); diff --git a/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java b/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java index 7956adc..196b4a1 100644 --- a/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java +++ b/src/main/java/cn/teammodel/service/impl/ChatMessageServiceImpl.java @@ -392,8 +392,10 @@ public class ChatMessageServiceImpl implements ChatMessageService { } } int count = 1; - //昵称 - builder.append(String.format(finalChatModel.getChat().get(0), chatCommentsDto.getName())); + if(finalChatModel.getChat() != null && !chatCommentsDto.getName().isEmpty()){ + //昵称 + builder.append(String.format(finalChatModel.getChat().get(0), chatCommentsDto.getName())); + } for (WisdomExamCommentsDto examComment : examComments) { builder.append(String.format(finalChatModel.getCycleChats().get(0), count, examComment.getName(), examComment.getTime(), examComment.getScore(), examComment.getScoreRate(), @@ -409,15 +411,21 @@ public class ChatMessageServiceImpl implements ChatMessageService { case "wisdomSubject": { List subjectComments; try { - subjectComments = JSON.parseObject(strData, new TypeReference>() { - }); + subjectComments = JSON.parseObject(strData, new TypeReference>() {}); } catch (Exception e) { throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常"); } if (subjectComments.isEmpty()) { throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常"); } - builder.append(String.format(finalChatModel.getChat().get(0), chatCommentsDto.getName())); + if(finalChatModel.getChat() != null && !chatCommentsDto.getName().isEmpty()){ + builder.append(String.format(finalChatModel.getChat().get(1), chatCommentsDto.getName())); + } + else { + if (finalChatModel.getChat() != null) { + builder.append(finalChatModel.getChat().get(0)); + } + } String name = ""; //拼接学科数组 for (WisdomSubjectComments comments : subjectComments) { @@ -447,7 +455,13 @@ public class ChatMessageServiceImpl implements ChatMessageService { throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常"); } } - builder.append(String.format(finalChatModel.getChat().get(0), chatCommentsDto.getName())); + if(finalChatModel.getChat() != null && !chatCommentsDto.getName().isEmpty()) { + builder.append(String.format(finalChatModel.getChat().get(1), chatCommentsDto.getName())); + }else { + if (finalChatModel.getChat() != null) { + builder.append(finalChatModel.getChat().get(0)); + } + } for (ArtLatitudeDto artLatitude : artLatitudes) { builder.append(String.format(finalChatModel.getCycleChats().get(0), artLatitude.getQuotaN1(),artLatitude.getQuotaP1(), artLatitude.getQuotaN2(),artLatitude.getQuotaP2(), artLatitude.getQuotaN3(),artLatitude.getQuotaP3(), artLatitude.getPercent(),artLatitude.getLevel())); @@ -469,7 +483,7 @@ public class ChatMessageServiceImpl implements ChatMessageService { throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常"); } } - builder.append(finalChatModel.getChat()); + builder.append(String.format(finalChatModel.getChat().get(0), chatCommentsDto.getSubject())); for (ArtSubjectDto artSubject : artSubjects){ builder.append(String.format(finalChatModel.getCycleChats().get(0), artSubject.getDimension(),artSubject.getBlock(), artSubject.getPoint(),artSubject.getScore(), artSubject.getTotalScore(),artSubject.getPercent())); } @@ -498,9 +512,11 @@ public class ChatMessageServiceImpl implements ChatMessageService { if (chatCommentsDto.getSize() > 0) { builder.append("限制条件如下:1、") .append(chatCommentsDto.getSize()) - .append("字左右;2、返回评语内容,不要开头提示语,开头不出现特殊字符。"); + .append("字左右;2、返回评语内容;不要开头提示语;开头不允许出现特殊字符。"); + //.append("字左右;2、返回评语的内容: 评语的开篇不允许出现提示语;评语的开篇不允许出现特殊字符。"); } else { - builder.append("限制条件如下:1、200字左右;2、返回评语内容;不要开头提示语;开头允许出现特殊字符。"); + builder.append("限制条件如下:1、200字左右;2、返回评语内容;不要开头提示语;开头不允许出现特殊字符。"); + //builder.append("限制条件如下:1、200字左右;2、返回评语的内容: 评语的开篇不允许出现提示语;评语的开篇不允许出现特殊字符。"); } return builder.toString(); } catch (Exception e) { diff --git a/src/main/resources/Json/ChatModel.json b/src/main/resources/Json/ChatModel.json index b7baa58..2c61520 100644 --- a/src/main/resources/Json/ChatModel.json +++ b/src/main/resources/Json/ChatModel.json @@ -5,7 +5,7 @@ "name": "智育 总体评语模版", "role": ["请扮演[%s%s]老师角色;\n 数据如下:"], "chat": ["%s同学,在%s学年度,第%s学期中,共计参加了%s次评测,其中课中评测%s次、线上评测%s次、阅卷评测%s次,素养等级为%s,已超过班级%s%% 的同学。\n %s同学的总体表现:", - "%s,在%s学年度,第%s学期,共计参加了%s次评测,其中课中评测%s次、线上评测%s次、阅卷评测%s次,总体表现:" + "%s,在%s学年度,第%s学期,共计参加了%s次评测,其中课中评测%s次、线上评测%s次、阅卷评测%s次,总体表现如下:" ], "cycleChats": ["在%s中:学习态度为:%s、学习成效:%s、合作能力:%s、评价能力:%s、评价能力:%s ;\n"], "end": ["请根据我提供的数据,对这 %s 次考试成绩表现做一个评价。\n"] @@ -22,7 +22,7 @@ "type": "wisdomSubject", "name": "智育 学科评语模版", "role": ["请扮演[%s%s]老师角色; 数据如下:\n"], - "chat": ["%s各科评测表现"], + "chat": ["的各科评测表现:","%s的各科评测表现:\""], "cycleChats":["科目:%s 班级top10"," 排名:%s,姓名:%s,得分率:%s %% ,\n " ,"%s在班级排名:%s,得分率:%s %%,排在班级平均得分率:(%s %%)"], "end": ["请根据我提供的数据,对这%s门学科,【%s】的表现做一个评价。 \n"] }, @@ -30,7 +30,7 @@ "type": "artLatitude", "name": "艺术 考核指标评语模版", "role": ["请扮演[%s%s]老师角色;数据如下:\n"], - "chat": ["%s的考核指标评纬度\n"], + "chat": ["考核指标评纬度\n","%s的考核指标评纬度\n"], "cycleChats": [" 一级指标:%s( %s %%);二级指标:%s( %s %%);三级指标 %s( %s %%) ;得分率:%s %% 等级:%s\n"], "end": ["请根据我提供的【考核指标纬度】做一个整体的评价。 \n"] }, @@ -38,7 +38,7 @@ "type": "artSubject", "name": "艺术 学科评语模版", "role": ["请扮演[%s%s]老师角色;数据如下:\n "], - "chat": ["%s学科\n"], + "chat": ["%s的学科\n"], "cycleChats": [" 考核纬度:%s;一级知识点:%s;二级知识点 %s;得分:%s/%s 得分率:%s\n"], "end": ["请根据我提供的【%s学科】的表现做一个整体的评价。 \n"] }