Skip to content

Commit

Permalink
refactor: Add support for Unix-style paths across all OS
Browse files Browse the repository at this point in the history
  • Loading branch information
kooqooo committed Aug 8, 2024
1 parent 8e826fe commit 67f5197
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pages/2_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sys.path.append("./")
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))

from config import DATA_DIR, IMG_PATH, path
from config import DATA_DIR, IMG_PATH, path, CSS_PATH
from loguru import logger as _logger
from src.logger import DevConfig
from src.util import (check_essential, get_image_base64, local_css,
Expand Down Expand Up @@ -48,7 +48,7 @@

st.title("안녕하세요, " + st.session_state.nickname + "님!") # 사용자 이름을 받아서 화면에 출력합니다.

local_css(os.path.join(path, "front", "css", "background.css"))
local_css(os.path.join(CSS_PATH, "background.css"))


# local_css("css/1_user.css")
Expand Down Expand Up @@ -237,7 +237,7 @@


## read job info tb
job_info, JOBS = read_job_info_tb(path + "/data/samples/job_info_tb.parquet")
job_info, JOBS = read_job_info_tb(os.path.join(DATA_DIR, "samples", "job_info_tb.parquet"))
st.session_state.job_info = job_info
st.session_state.logger.info("read job tb")
st.session_state.logger.info(f"job info is ... {JOBS}")
Expand Down
6 changes: 3 additions & 3 deletions pages/3_gene_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@

### JD 사용하여 JD 추출용 프롬프트 만들기
st.session_state.logger.info("prompt JD start")
prompt_template_jd = read_prompt_from_txt(os.path.join(DATA_DIR, "test/prompt_JD_template.txt"))
prompt_template_jd = read_prompt_from_txt(os.path.join(DATA_DIR, "test", "prompt_JD_template.txt"))
st.session_state.prompt_JD = create_prompt_with_jd(prompt_template_jd)

# prompt_JD 생성완료
Expand All @@ -163,7 +163,7 @@
# prompt_qa_template #######################################

st.session_state.logger.info("prompt resume start")
prompt_template_resume = read_prompt_from_txt(os.path.join(DATA_DIR, "test/prompt_resume_template.txt"))
prompt_template_resume = read_prompt_from_txt(os.path.join(DATA_DIR, "test", "prompt_resume_template.txt"))

st.session_state.logger.info("create prompt resume template")
st.session_state.prompt_resume = create_prompt_with_resume(prompt_template_resume)
Expand Down Expand Up @@ -192,7 +192,7 @@

## step3 :
st.session_state.logger.info("prompt question start")
prompt_template_question = read_prompt_from_txt(os.path.join(DATA_DIR, "test/prompt_question_template.txt"))
prompt_template_question = read_prompt_from_txt(os.path.join(DATA_DIR, "test", "prompt_question_template.txt"))

st.session_state.logger.info("create prompt question template")
st.session_state.prompt_question = create_prompt_with_question(prompt_template_question)
Expand Down
4 changes: 2 additions & 2 deletions pages/3_gene_question_no_resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@

### JD 사용하여 JD 추출용 프롬프트 만들기
st.session_state.logger.info("prompt JD start")
prompt_template_jd = read_prompt_from_txt(os.path.join(DATA_DIR, "test/prompt_JD_template.txt"))
prompt_template_jd = read_prompt_from_txt(os.path.join(DATA_DIR, "test", "prompt_JD_template.txt"))
st.session_state.prompt_JD = create_prompt_with_jd(prompt_template_jd)

# prompt_JD 생성완료
Expand All @@ -148,7 +148,7 @@

## step2 JD 만을 이용해 질문 6개를 생성합니다 :
st.session_state.logger.info("prompt question start")
prompt_noResume_question_template = read_prompt_from_txt(os.path.join(DATA_DIR, "test/prompt_noResume_question_template.txt"))
prompt_noResume_question_template = read_prompt_from_txt(os.path.join(DATA_DIR, "test", "prompt_noResume_question_template.txt"))

st.session_state.logger.info("create no resume prompt question template")
st.session_state.prompt_question = create_prompt_with_no_resume(prompt_noResume_question_template)
Expand Down
2 changes: 1 addition & 1 deletion pages/4_interview.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def next_tail_question():

# 대화내역 파일로 저장
st.session_state.interview_script_download = "\n\n".join(st.session_state.interview_script)
with open(st.session_state['save_dir'] + "/interview_history.txt", "w") as file:
with open(os.path.join(st.session_state['save_dir'], "interview_history.txt"), "w") as file:
file.write(st.session_state.interview_script_download)

##################################### 여기서부터 모의 면접 시작 ############################################
Expand Down
6 changes: 3 additions & 3 deletions pages/4_show_questions_hint.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@

st.title(f"{st.session_state.user_name}님의 기술면접 예상 질문입니다.🤗 ")

st.session_state.prompt_template_fb = read_prompt_from_txt(os.path.join(DATA_DIR, "test/prompt_feedback.txt"))
st.session_state.prompt_template_ht = read_prompt_from_txt(os.path.join(DATA_DIR, "test/prompt_hint.txt"))
st.session_state.prompt_template_fb = read_prompt_from_txt(os.path.join(DATA_DIR, "test", "prompt_feedback.txt"))
st.session_state.prompt_template_ht = read_prompt_from_txt(os.path.join(DATA_DIR, "test", "prompt_hint.txt"))


# 각 질문에 대해 번호를 매기고 토글 위젯 생성
Expand Down Expand Up @@ -140,7 +140,7 @@
switch_page("user")

st.session_state.question_history = "\n\n".join(st.session_state.questions_showhint)
with open(st.session_state['save_dir'] + "/question_history.txt", "w") as file:
with open(os.path.join(st.session_state['save_dir'], "question_history.txt"), "w") as file:
file.write(st.session_state.question_history) # 생성된 질문을 파일로 저장

# 다운로드 버튼 생성
Expand Down
6 changes: 2 additions & 4 deletions src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from langchain.memory.buffer_window import ConversationBufferWindowMemory
from langchain.prompts.prompt import PromptTemplate
from PIL import Image
from dotenv import load_dotenv
from config import DATA_DIR

sys.path.append("./")
load_dotenv() # OPENAI_API_KEY 불러오기
Expand Down Expand Up @@ -214,9 +214,7 @@ def load_chain(question):

# Load OpenAI chat model
llm = ChatOpenAI(temperature=0)
template = read_prompt_from_txt(
os.path.join(os.path.dirname(os.path.dirname(__file__)), "data", "test", "tail_question_template.txt")
)
template = read_prompt_from_txt(os.path.join(DATA_DIR, "test", "tail_question_template.txt"))

# Create memory 'chat_history'
memory = ConversationBufferWindowMemory(human_prefix="면접자 답변", ai_prefix="answer")
Expand Down

0 comments on commit 67f5197

Please sign in to comment.