Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,71 +1,69 @@
|
|
1 |
import streamlit as st
|
2 |
from langchain.chat_models import ChatOpenAI
|
3 |
-
from langchain.prompts import
|
|
|
4 |
from langchain.chains import LLMChain
|
|
|
5 |
from PyPDF2 import PdfReader
|
6 |
import os
|
7 |
|
8 |
# Streamlit UI setup
|
9 |
st.set_page_config(page_title="AI Job Interview Prep Tool")
|
10 |
-
st.title("
|
11 |
|
12 |
-
#
|
13 |
openai_key = st.text_input("π Enter your OpenAI API Key", type="password")
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# User Inputs
|
16 |
-
company = st.text_input("
|
17 |
-
profile = st.text_input("
|
18 |
-
jd = st.text_area("
|
19 |
-
resume_file = st.file_uploader("
|
20 |
|
21 |
-
# Extract text from PDF if resume is uploaded
|
22 |
resume_text = ""
|
23 |
if resume_file is not None:
|
24 |
-
|
25 |
-
for page in
|
26 |
resume_text += page.extract_text() or ""
|
27 |
|
28 |
-
#
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
base_prompt = PromptTemplate(
|
43 |
-
input_variables=["company", "profile", "jd", "resume"],
|
44 |
-
template="""
|
45 |
-
You are an expert HR and Technical Interviewer.
|
46 |
-
Given the following details:
|
47 |
Company: {company}
|
48 |
Profile: {profile}
|
49 |
Job Description: {jd}
|
50 |
-
Resume (
|
51 |
|
52 |
-
|
53 |
-
- Round 1: Technical Interview (7-10 questions including 2 hands-on tasks)
|
54 |
-
- Round 2: Technical + Case Study (7-10 questions including at least 1 scenario or case-study based question)
|
55 |
-
- Round 3: Business and HR Round (7-10 questions focused on communication, decision making, and company alignment)
|
56 |
-
|
57 |
-
Present the questions grouped by round in clear bullet format using Markdown.
|
58 |
"""
|
59 |
-
|
|
|
|
|
|
|
60 |
|
61 |
-
|
|
|
62 |
response = chain.run({
|
63 |
"company": company,
|
64 |
"profile": profile,
|
65 |
"jd": jd,
|
66 |
-
"resume": resume_text
|
67 |
})
|
68 |
-
|
69 |
-
st.
|
70 |
-
st.markdown(response)
|
71 |
-
|
|
|
1 |
import streamlit as st
|
2 |
from langchain.chat_models import ChatOpenAI
|
3 |
+
from langchain.prompts import ChatPromptTemplate
|
4 |
+
from langchain.schema.runnable import RunnableLambda
|
5 |
from langchain.chains import LLMChain
|
6 |
+
from langchain.prompts import PromptTemplate
|
7 |
from PyPDF2 import PdfReader
|
8 |
import os
|
9 |
|
10 |
# Streamlit UI setup
|
11 |
st.set_page_config(page_title="AI Job Interview Prep Tool")
|
12 |
+
st.title("AI-Powered Job Interview Preparation")
|
13 |
|
14 |
+
# OpenAI API Key input
|
15 |
openai_key = st.text_input("π Enter your OpenAI API Key", type="password")
|
16 |
+
if not openai_key:
|
17 |
+
st.warning("Please enter your OpenAI API Key to continue.")
|
18 |
+
st.stop()
|
19 |
+
|
20 |
+
os.environ["OPENAI_API_KEY"] = openai_key
|
21 |
|
22 |
# User Inputs
|
23 |
+
company = st.text_input("Company Name")
|
24 |
+
profile = st.text_input("Profile Name")
|
25 |
+
jd = st.text_area("Job Description")
|
26 |
+
resume_file = st.file_uploader("Upload Resume (Optional)", type=["pdf"])
|
27 |
|
|
|
28 |
resume_text = ""
|
29 |
if resume_file is not None:
|
30 |
+
pdf_reader = PdfReader(resume_file)
|
31 |
+
for page in pdf_reader.pages:
|
32 |
resume_text += page.extract_text() or ""
|
33 |
|
34 |
+
# Prompt Template
|
35 |
+
template = PromptTemplate(
|
36 |
+
input_variables=["company", "profile", "jd", "resume"],
|
37 |
+
template="""
|
38 |
+
You are an AI interview coach.
|
39 |
+
Generate:
|
40 |
+
- 2 technical rounds with 7-10 questions each
|
41 |
+
- Each technical round should have:
|
42 |
+
- Conceptual questions
|
43 |
+
- 2-3 hands-on tasks (code-oriented)
|
44 |
+
- 1 case-study type question
|
45 |
+
- 1 business + HR round with 7-10 questions
|
46 |
|
47 |
+
Base the questions on the job description, company, profile and resume.
|
|
|
|
|
|
|
|
|
|
|
48 |
Company: {company}
|
49 |
Profile: {profile}
|
50 |
Job Description: {jd}
|
51 |
+
Resume (optional): {resume}
|
52 |
|
53 |
+
Provide questions clearly labeled under each round.
|
|
|
|
|
|
|
|
|
|
|
54 |
"""
|
55 |
+
)
|
56 |
+
|
57 |
+
llm = ChatOpenAI(temperature=0.7)
|
58 |
+
chain = LLMChain(llm=llm, prompt=template)
|
59 |
|
60 |
+
if st.button("Generate Interview Rounds"):
|
61 |
+
with st.spinner("Generating questions..."):
|
62 |
response = chain.run({
|
63 |
"company": company,
|
64 |
"profile": profile,
|
65 |
"jd": jd,
|
66 |
+
"resume": resume_text,
|
67 |
})
|
68 |
+
st.subheader("π Interview Questions")
|
69 |
+
st.write(response)
|
|
|
|