-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
74 lines (52 loc) · 2.46 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import streamlit as st
import os
from pathlib import Path
from PIL import Image
from utils import utils
from lyzr_qabot import ai_interviewer
utils.page_config()
data = "data"
os.makedirs(data, exist_ok=True)
image = Image.open("./logo/lyzr-logo.png")
st.image(image, width=150)
st.title('AI Interviewer 👩🏻💻💬')
st.markdown('Welcome to the lyzr AI Interviewer app, this app will help you to prepare your upcoming interviews !!!')
def interviwer(path, filetype):
interview_agent = ai_interviewer(path=path, file=filetype)
metric = "Extract all the skills from the given file"
skills = interview_agent.query(metric)
return skills.response
def gpt_interview_questions(qabot_response):
question_response = utils.llm_calling(user_prompt=f"Create one interview question on based on this skill set {qabot_response}, [!important] question should not more than 2 line make it very specific",
system_prompt=f"You are an interview expert",llm_model="gpt-4-turbo-preview")
answer_response = utils.llm_calling(user_prompt=f"Generate answer for this {question_response}, [!Important] answer should not more than 3 lines, make it simple",
system_prompt=f"You are an interview expert",llm_model="gpt-4-turbo-preview")
return question_response, answer_response
def question_answer_session(typefile):
path = utils.get_files_in_directory(data)
filepath = path[0]
qa_response = interviwer(path=filepath, filetype=typefile)
question, gpt_answer = gpt_interview_questions(qabot_response=qa_response)
st.header(question)
# answer = st.text_input('Write your response')
# if answer:
# st.write(answer)
st.markdown('---')
st.subheader('Reference Answer')
st.write(gpt_answer)
def main():
st.sidebar.image(image, width=150)
file = st.sidebar.file_uploader("Upload your resume", type=["pdf", "docx"])
if file is None:
st.subheader('👈 Upload your resume to get started!!!')
utils.remove_existing_files(data)
if file is not None:
utils.save_uploaded_file(file, directory_name=data)
typefile = Path(file.name).suffix
if st.sidebar.button('Next'):
question_answer_session(typefile=typefile)
st.sidebar.info('Click this 👆 Button to generate Interview Questions')
if __name__ == "__main__":
utils.style_app()
main()
utils.template_end()