Skip to content

Commit b8c0f84

Browse files
committed
refactor: PromptBuilder 도메인별 분리 (#80)
1 parent 49b0ab6 commit b8c0f84

5 files changed

Lines changed: 100 additions & 76 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package io.wisoft.prepair.prepair_api.interview.prompt;
2+
3+
import io.wisoft.prepair.prepair_api.interview.answer.dto.internal.FinalFeedbackInput;
4+
import org.springframework.stereotype.Component;
5+
6+
import java.util.List;
7+
import java.util.stream.Collectors;
8+
9+
@Component
10+
public class FeedbackPromptBuilder {
11+
12+
public String buildFeedbackPrompt(String question, String questionTag, String answer) {
13+
return """
14+
너는 %s 관련 직무 분야의 면접 전문가야. 질문의 맥락을 먼저 파악한 후, 해당 분야의 기준에 맞춰 답변을 평가해줘.
15+
16+
규칙:
17+
1. good: 답변에서 잘한 점을 작성해줘.
18+
2. improvement: 부족한 부분을 구체적으로 작성해줘.
19+
3. recommendation: 개선 방향을 제안해줘.
20+
4. score: 0~100 사이 정수로 점수를 매겨줘.
21+
5. 답변이 질문과 무관하거나 내용이 없는 경우, score는 0~10점으로 매기고 good은 "없음"으로 작성해줘.
22+
6. 반드시 아래 JSON 형식으로만 응답하고, 마크다운(```json 등)은 포함하지 마.
23+
{\
24+
"good": "잘한 점",
25+
"improvement": "부족한 점",
26+
"recommendation": "개선 방향",
27+
"score": 85
28+
}
29+
30+
질문: %s
31+
답변: %s
32+
""".formatted(questionTag, question, answer);
33+
}
34+
35+
public String buildCombinedFeedbackPrompt(String question, String sttFeedback, String videoFeedback) {
36+
return """
37+
너는 면접 평가 전문가야. 아래 면접 질문에 대한 음성 분석(STT) 피드백과 영상 분석(Video) 피드백을 종합하여 한 줄 종합 평가를 작성해줘.
38+
39+
규칙:
40+
1. 음성 분석과 영상 분석의 내용을 모두 고려하여 종합적으로 평가해줘.
41+
2. combineFeedback: 한 줄로 종합 평가를 작성해줘.
42+
3. score: 0~100 사이 정수로 종합 점수를 매겨줘.
43+
4. 반드시 아래 JSON 형식으로만 응답하고, 마크다운(```json 등)은 포함하지 마.
44+
{
45+
"combineFeedback": "한 줄 종합 평가",
46+
"score": 85
47+
}
48+
49+
면접 질문: %s
50+
51+
음성 분석 피드백:
52+
%s
53+
54+
영상 분석 피드백:
55+
%s
56+
""".formatted(question, sttFeedback, videoFeedback);
57+
}
58+
59+
public String buildFinalFeedbackPrompt(List<FinalFeedbackInput> inputs) {
60+
String questionsAndFeedbacks = inputs.stream()
61+
.map(input -> """
62+
질문: %s
63+
종합 평가: %s
64+
점수: %d
65+
66+
""".formatted(
67+
input.question(),
68+
input.combinedFeedback(),
69+
input.score()
70+
))
71+
.collect(Collectors.joining());
72+
73+
return """
74+
너는 면접 평가 전문가야. 아래는 한 면접 세션에서 진행된 모든 질문과 각 질문에 대한 종합 평가 결과야.
75+
이를 바탕으로 면접자의 전체적인 면접 수행에 대한 최종 평가 요약을 작성해줘.
76+
77+
규칙:
78+
1. 전체 질문에 대한 답변 경향, 강점, 약점을 종합적으로 분석해줘.
79+
2. finalFeedback: 2-3문장으로 최종 평가 요약을 작성해줘.
80+
3. 반드시 아래 JSON 형식으로만 응답하고, 마크다운(```json 등)은 포함하지 마.
81+
{
82+
"finalFeedback": "최종 평가 요약"
83+
}
84+
85+
면접 질문 및 종합 평가 결과:
86+
%s
87+
""".formatted(questionsAndFeedbacks);
88+
}
89+
}

src/main/java/io/wisoft/prepair/prepair_api/interview/prompt/PromptBuilder.java renamed to src/main/java/io/wisoft/prepair/prepair_api/interview/prompt/QuestionPromptBuilder.java

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.util.List;
77

88
@Component
9-
public class PromptBuilder {
9+
public class QuestionPromptBuilder {
1010

1111
public String buildDailyQuestionPrompt(String job, List<InterviewQuestion> previousQuestions) {
1212
StringBuilder prompt = new StringBuilder();
@@ -34,11 +34,11 @@ public String buildDailyQuestionPrompt(String job, List<InterviewQuestion> previ
3434
}
3535

3636
public String buildCompanyQuestionPrompt(String jobPostingContent) {
37-
return """
37+
return """
3838
너는 채용공고 내용을 분석하여 실제 그 기업의 면접을 진행하는 면접관이야.
39-
39+
4040
아래 채용공고 정보를 바탕으로 지원자에게 물어볼 면접 질문 5개를 만들고, 관련 키워드 태그 2-3개를 추출해줘.
41-
41+
4242
규칙:
4343
1. 채용공고의 기술 스택, 자격 요건, 담당 업무를 반드시 반영해줘.
4444
2. 반드시 아래 JSON 형식으로만 응답하고, 다른 텍스트는 포함하지 마.
@@ -65,13 +65,12 @@ public String buildCompanyQuestionPrompt(String jobPostingContent) {
6565
"tags": ["태그1", "태그2", "태그3"]
6666
}
6767
]
68-
68+
6969
채용공고 정보:
7070
%s
7171
""".formatted(jobPostingContent);
7272
}
7373

74-
7574
public String buildVideoQuestionPrompt(String job, int count) {
7675
return """
7776
너는 %s 직무의 실제 면접을 진행하는 면접관이야.
@@ -91,70 +90,4 @@ public String buildVideoQuestionPrompt(String job, int count) {
9190
]
9291
""".formatted(job, count);
9392
}
94-
95-
public String buildFeedbackPrompt(String question, String questionTag, String answer) {
96-
97-
return """
98-
너는 %s 관련 직무 분야의 면접 전문가야. 질문의 맥락을 먼저 파악한 후, 해당 분야의 기준에 맞춰 답변을 평가해줘.
99-
100-
규칙:
101-
1. good: 답변에서 잘한 점을 작성해줘.
102-
2. improvement: 부족한 부분을 구체적으로 작성해줘.
103-
3. recommendation: 개선 방향을 제안해줘.
104-
4. score: 0~100 사이 정수로 점수를 매겨줘.
105-
5. 답변이 질문과 무관하거나 내용이 없는 경우, score는 0~10점으로 매기고 good은 "없음"으로 작성해줘.
106-
6. 반드시 아래 JSON 형식으로만 응답하고, 마크다운(```json 등)은 포함하지 마.
107-
{\
108-
"good": "잘한 점",
109-
"improvement": "부족한 점",
110-
"recommendation": "개선 방향",
111-
"score": 85
112-
}
113-
114-
질문: %s
115-
답변: %s
116-
""".formatted(questionTag, question, answer);
117-
}
118-
119-
public String buildCombinedFeedbackPrompt(String question, String sttFeedback, String videoFeedback) {
120-
return """
121-
너는 면접 평가 전문가야. 아래 면접 질문에 대한 음성 분석(STT) 피드백과 영상 분석(Video) 피드백을 종합하여 한 줄 종합 평가를 작성해줘.
122-
123-
규칙:
124-
1. 음성 분석과 영상 분석의 내용을 모두 고려하여 종합적으로 평가해줘.
125-
2. combineFeedback: 한 줄로 종합 평가를 작성해줘.
126-
3. score: 0~100 사이 정수로 종합 점수를 매겨줘.
127-
4. 반드시 아래 JSON 형식으로만 응답하고, 마크다운(```json 등)은 포함하지 마.
128-
{
129-
"combineFeedback": "한 줄 종합 평가",
130-
"score": 85
131-
}
132-
133-
면접 질문: %s
134-
135-
음성 분석 피드백:
136-
%s
137-
138-
영상 분석 피드백:
139-
%s
140-
""".formatted(question, sttFeedback, videoFeedback);
141-
}
142-
143-
public String buildFinalFeedbackPrompt(String questionsAndFeedbacks) {
144-
return """
145-
너는 면접 평가 전문가야. 아래는 한 면접 세션에서 진행된 모든 질문과 각 질문에 대한 종합 평가 결과야.
146-
이를 바탕으로 면접자의 전체적인 면접 수행에 대한 최종 평가 요약을 작성해줘.
147-
148-
규칙:
149-
1. 전체 질문에 대한 답변 경향, 강점, 약점을 종합적으로 분석해줘.
150-
2. finalFeedback: 2-3문장으로 최종 평가 요약을 작성해줘.
151-
3. 반드시 아래 JSON 형식으로만 응답하고, 마크다운(```json 등)은 포함하지 마.
152-
{
153-
"finalFeedback": "최종 평가 요약"
154-
}
155-
156-
면접 질문 및 종합 평가 결과:
157-
%s
158-
""".formatted(questionsAndFeedbacks);
159-
}
16093
}

src/main/java/io/wisoft/prepair/prepair_api/interview/prompt/VideoAnalysisPromptBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ public String buildVisionPrompt() {
3232
}
3333
""";
3434
}
35+
36+
3537
}

src/main/java/io/wisoft/prepair/prepair_api/interview/question/service/QuestionService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import io.wisoft.prepair.prepair_api.external.member.dto.MemberSchedulerInfo;
1616
import io.wisoft.prepair.prepair_api.external.openai.OpenAiClient;
1717
import io.wisoft.prepair.prepair_api.external.openai.dto.QuestionWithTags;
18-
import io.wisoft.prepair.prepair_api.interview.prompt.PromptBuilder;
18+
import io.wisoft.prepair.prepair_api.interview.prompt.QuestionPromptBuilder;
1919
import io.wisoft.prepair.prepair_api.interview.question.repository.QuestionRepository;
2020

2121
import io.wisoft.prepair.prepair_api.interview.jobposting.service.JobPostingService;
@@ -39,7 +39,7 @@ public class QuestionService {
3939
private final QuestionRepository questionRepository;
4040
private final MemberServiceClient memberServiceClient;
4141
private final OpenAiClient openAiClient;
42-
private final PromptBuilder promptBuilder;
42+
private final QuestionPromptBuilder promptBuilder;
4343

4444
public List<QuestionResponse> getQuestions(UUID memberId, QuestionType type) {
4545
return questionRepository.findByMemberIdAndQuestionTypeOrderByCreatedAtDesc(memberId, type)

src/main/java/io/wisoft/prepair/prepair_api/interview/question/service/TodayQuestionService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import io.wisoft.prepair.prepair_api.external.member.dto.MemberSchedulerInfo;
55
import io.wisoft.prepair.prepair_api.external.openai.OpenAiClient;
66
import io.wisoft.prepair.prepair_api.external.openai.dto.QuestionWithTags;
7-
import io.wisoft.prepair.prepair_api.interview.prompt.PromptBuilder;
7+
import io.wisoft.prepair.prepair_api.interview.prompt.QuestionPromptBuilder;
88
import io.wisoft.prepair.prepair_api.interview.question.entity.InterviewQuestion;
99
import io.wisoft.prepair.prepair_api.interview.question.repository.QuestionRepository;
1010
import lombok.RequiredArgsConstructor;
@@ -26,7 +26,7 @@ public class TodayQuestionService {
2626
private final QuestionRepository questionRepository;
2727
private final MemberServiceClient memberServiceClient;
2828
private final OpenAiClient openAiClient;
29-
private final PromptBuilder promptBuilder;
29+
private final QuestionPromptBuilder promptBuilder;
3030

3131
public void sendTodayQuestions() {
3232
List<MemberSchedulerInfo> members = memberServiceClient.getMembers();

0 commit comments

Comments
 (0)