Skip to content

Commit

Permalink
refactor: 서술형 문제 채점시 프롬프트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
starwook committed Jan 13, 2025
1 parent 2f41e01 commit 675cca9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CommentController(
val comments: List<ResponseCommentDto> = commentService.getComments(questionId, user)
model.addAttribute("multipleChoice", true)
model.addAttribute("comments", comments)
val question = questionGetService.getQuestionByIdFetchChoiceIfShould(questionId)
val question = questionGetService.getQuestionById(questionId)
model.addAttribute(
"question",
ResponseQuestionDto.from(question),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DescriptiveQuestionService(
questionGetService.getMajorDescriptiveQuestion(id)

return chatManageService.talkForGradeDescriptiveQuestion(
question.gradeStandard,
systemMessage + question.gradeStandard,
question.content,
requestDoGradeDescriptiveAnswerDto.content,
)
Expand All @@ -34,4 +34,15 @@ class DescriptiveQuestionService(
question.changeGradeStandard(requestChangeQuestionGradeStandardDto.gradeStandard)
return question
}

private val systemMessage =
"당신은 면접관입니다. 사용자는 면접을 보는 사람입니다. " +
"주어진 채점 기준에 맞추어 작성자의 답변을 점검해주세요. " +
"사용자의 답변에 아쉬운 부분이 있다면 과감히 말씀해주세요. " +
"1. 예를 들어 A에 대해 물어봤는데 답변자가 관련성이 적은 B까지 언급한다면, 지적해주셔도 됩니다. " +
"2. 사용자가 틀린 내용을 말한다면 틀렸다고 말씀해주세요." +
"채점 기준에 사용자의 답변이 부합하지 않더라도, 채점 기준이 무조건 적인 정답이 되어선 안됩니다." +
"그러니 지적할 때, ~이렇게 대답하셔야합니다. 보단 ~ 이런 내용을 보충하시면 더 좋을 거같습니다. 이런 식으로 지적해주세요." +
"문제 채점 기준은 다음과 같습니다. 주어진 채점 기준이 없다면 당신이 임의로 판단해서 채점해주세요. " +
""
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import org.springframework.transaction.annotation.Transactional
class QuestionGetService(
private val questionRepository: QuestionRepository,
) {
fun getQuestionByIdFetchChoiceIfShould(questionId: Long): Question {
fun getQuestionById(questionId: Long): Question {
val question =
questionRepository.findById(questionId).orElseThrow { NoSuchElementException() }
?: throw NoSuchElementException("Question with ID $questionId not found")
// MajorMultipleChoiceQuestion 타입이면 choices를 지연 로딩
when (question) {
is MajorMultipleChoiceQuestion -> {
question.questionChoices.size // 지연 로딩 강제 초기화
Expand All @@ -27,8 +26,6 @@ class QuestionGetService(
is LicenseMultipleChoiceQuestion -> {
question.questionChoices.size // 지연 로딩 강제 초기화
}

else -> throw WrongQuestionTypeException()
}
return question
}
Expand Down

0 comments on commit 675cca9

Please sign in to comment.