File size: 2,358 Bytes
7b63c33
b77f9d0
 
 
 
 
 
 
 
 
 
 
 
 
4211395
b77f9d0
 
 
 
 
 
 
 
 
 
 
 
 
7b63c33
b77f9d0
 
7b63c33
b77f9d0
 
 
 
 
 
7b63c33
b77f9d0
 
 
 
 
 
 
 
 
 
7b63c33
b77f9d0
 
 
 
7b63c33
b77f9d0
 
 
7b63c33
b77f9d0
 
 
 
 
 
 
7b63c33
b77f9d0
 
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
import streamlit as st
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema.runnable import RunnableLambda
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from PyPDF2 import PdfReader
import os

# Streamlit UI setup
st.set_page_config(page_title="AI Job Interview Prep Tool")
st.title("AI-Powered Job Interview Preparation")

# It's good practice to load these from a .env file, but for demonstration purposes, we are setting them directly
os.environ["OPENAI_API_KEY"] = os.environ.get("s1")

# User Inputs
company = st.text_input("Company Name")
profile = st.text_input("Profile Name")
jd = st.text_area("Job Description")
resume_file = st.file_uploader("Upload Resume (Optional)", type=["pdf"])

# Extract text from PDF if resume is uploaded
resume_text = ""
if resume_file is not None:
    pdf = PdfReader(resume_file)
    for page in pdf.pages:
        resume_text += page.extract_text()

# Submit button
submit = st.button("Generate Interview Questions")

if submit:
    if not company or not profile or not jd:
        st.warning("Please fill in all mandatory fields.")
    else:
        # Set up OpenAI LLM
        llm = ChatOpenAI(temperature=0.7, model_name="gpt-4")

        # Prompt Template
        base_prompt = PromptTemplate(
            input_variables=["company", "profile", "jd", "resume"],
            template="""
You are an expert HR and Technical Interviewer.
Given the following details:
Company: {company}
Profile: {profile}
Job Description: {jd}
Resume (if provided): {resume}

Generate a structured set of interview questions:
- Round 1: Technical Interview (7-10 questions including 2 hands-on tasks)
- Round 2: Technical + Case Study (7-10 questions including at least 1 scenario or case-study based question)
- Round 3: Business and HR Round (7-10 questions focused on communication, decision making, and company alignment)

Present the questions grouped by round in clear bullet format.
            """
        )

        chain = LLMChain(llm=llm, prompt=base_prompt)
        response = chain.run({
            "company": company,
            "profile": profile,
            "jd": jd,
            "resume": resume_text or "Not Provided"
        })

        st.subheader("Suggested Interview Questions")
        st.write(response)