Skip to content

Commit

Permalink
fix: 초기질문 생성할 때 회사이름도 입력받도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
saebyeok0306 committed Nov 13, 2023
1 parent ac0b740 commit c6f58d4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
11 changes: 8 additions & 3 deletions moview/modules/input/initial_question_giver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ def __init__(self, prompt_loader: PromptLoader):

@async_retry()
async def give_initial_questions_by_input_data(
self, recruit_announcement: str, cover_letter: str, question_count: int, exclusion_list: List[str] = None
self, company_name, recruit_announcement: str, cover_letter: str, question_count: int, exclusion_list: List[str] = None
) -> List[str]:
"""
Args:
company_name: 회사 이름
recruit_announcement: 모집공고
cover_letter: 자기소개서
question_count: 출제할 질문 개수
Expand All @@ -34,6 +35,7 @@ async def give_initial_questions_by_input_data(
messages = [{
"role": "system",
"content": self.prompt["create_question_by_input_data"].format(
company_name=company_name,
exclusion_question=exclusion_question,
question_count=question_count)
}, {
Expand All @@ -55,10 +57,12 @@ async def give_initial_questions_by_input_data(
raise InitialQuestionParseError() # 파싱이 실패하면, InitialQuestionParseError를 발생시킵니다.

@async_retry()
async def give_initial_questions(self, job_group: str, question_count: int, exclusion_list: List[str] = None) -> \
List[str]:
async def give_initial_questions(
self, company_name:str, job_group: str, question_count: int, exclusion_list: List[str] = None
) -> List[str]:
"""
Args:
company_name: 회사 이름
job_group: 타겟 직군
question_count: 출제할 질문 개수
exclusion_list: 제외할 질문 리스트
Expand All @@ -71,6 +75,7 @@ async def give_initial_questions(self, job_group: str, question_count: int, excl
messages = [{
"role": "system",
"content": self.prompt["create_question"].format(
company_name=company_name,
exclusion_question=exclusion_question,
job_group=job_group,
question_count=question_count)
Expand Down
4 changes: 4 additions & 0 deletions moview/service/input_data_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ async def ask_initial_question_to_interviewee(
))
# 초기 질문 생성
create_initial_question_task = asyncio.create_task(self.__create_initial_question_list(
company_name=company_name,
job_group=job_group,
recruit_announcement=recruit_announcement,
cover_letter_questions=cover_letter_questions,
Expand Down Expand Up @@ -152,6 +153,7 @@ async def __analyze_initial_inputs_of_interviewee(

async def __create_initial_question_list(
self,
company_name: str,
job_group: str,
recruit_announcement: str,
cover_letter_questions: List[str],
Expand All @@ -173,6 +175,7 @@ async def __create_initial_question_list(

# 직군 정보만 가지고 초기질문 생성.
# created_questions = await self.initial_question_giver.give_initial_questions(
# company_name=company_name,
# job_group=job_group,
# question_count=self.INIT_QUESTION_NUMBER // 2
# )
Expand All @@ -187,6 +190,7 @@ async def __create_initial_question_list(

# 자기소개서와 모집공고를 기반으로 초기질문 생성.
created_questions = await self.initial_question_giver.give_initial_questions_by_input_data(
company_name=company_name,
recruit_announcement=recruit_announcement,
cover_letter=cover_letter,
question_count=self.INIT_QUESTION_NUMBER,
Expand Down
22 changes: 16 additions & 6 deletions tests/modules/input/test_inital_question_giver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ def setUp(self) -> None:

def test_load_prompt(self):
self.assertTrue(is_not_none_string(self.giver.prompt["create_question"]))
print(self.giver.prompt["create_question"].format(exclusion_question="", job_group="백엔드 개발자", question_count=2))
print(self.giver.prompt["create_question"].format(exclusion_question="", company_name="삼성 SDS", job_group="백엔드 개발자", question_count=2))

async def test_give_initial_questions_by_input_data(self):
company_name = "삼성 청년 SW 아카데미"
recruit_announcement = ("삼성 청년 SW 아카데미\n8기 모집 Coming soon\n청년 SW인재 양성을 위한 SSAFY 8기 모집이 곧 시작됩니다.\n궁금한 SSAFY 8기 "
"모집! 미리 알려드립니다!\n\n8기 모집 안내\n지원 자격\n만 29세 이하(92.7.1이후 출생자), 미취업자,\n국내외 4년제 대학 졸업자 및 "
"졸업예정자(전공무관)\n\n교육 기간\n2022년 7월 ~ 2023년 6월(1년)\n\n교육 장소\n서울, 대전, 구미, 광주, "
Expand All @@ -32,6 +33,7 @@ async def test_give_initial_questions_by_input_data(self):
question_count = 3

initial_questions = await self.giver.give_initial_questions_by_input_data(
company_name=company_name,
recruit_announcement=recruit_announcement,
cover_letter=cover_letter,
question_count=question_count
Expand All @@ -40,24 +42,32 @@ async def test_give_initial_questions_by_input_data(self):
self.assertTrue(len(initial_questions) == question_count)

async def test_give_initial_questions(self):
company_name = "삼성 SDS"
job_group = "백엔드 개발자"
question_count = 3

initial_questions = await self.giver.give_initial_questions(job_group=job_group,
question_count=question_count)
initial_questions = await self.giver.give_initial_questions(
company_name=company_name,
job_group=job_group,
question_count=question_count
)
print(initial_questions)
self.assertTrue(len(initial_questions) == question_count)

async def test_give_initial_questions_with_exclusion_list(self):
company_name = "삼성 SDS"
job_group = "백엔드 개발자"
question_count = 3
exclusion_list = [
"백엔드 개발자로서 가장 자신 있는 기술 영역은 무엇인가요?",
"이전에 개발한 백엔드 시스템에서 겪은 가장 큰 어려움은 무엇이었나요?"
]

initial_questions = await self.giver.give_initial_questions(job_group=job_group,
question_count=question_count,
exclusion_list=exclusion_list)
initial_questions = await self.giver.give_initial_questions(
company_name=company_name,
job_group=job_group,
question_count=question_count,
exclusion_list=exclusion_list
)
print(initial_questions)
self.assertLessEqual(len(initial_questions), question_count)

0 comments on commit c6f58d4

Please sign in to comment.