NEW_CALCULATION / app.py
YOUYOGITA's picture
Update app.py
a249ddd verified
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")
# OpenAI API Key input
openai_key = st.text_input("πŸ” Enter your OpenAI API Key", type="password")
if not openai_key:
st.warning("Please enter your OpenAI API Key to continue.")
st.stop()
os.environ["OPENAI_API_KEY"] = openai_key
# 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"])
resume_text = ""
if resume_file is not None:
pdf_reader = PdfReader(resume_file)
for page in pdf_reader.pages:
resume_text += page.extract_text() or ""
# Prompt Template
template = PromptTemplate(
input_variables=["company", "profile", "jd", "resume"],
template="""
You are an AI interview coach.
Generate:
- 2 technical rounds with 7-10 questions each
- Each technical round should have:
- Conceptual questions
- 2-3 hands-on tasks (code-oriented)
- 1 case-study type question
- 1 business + HR round with 7-10 questions
Base the questions on the job description, company, profile and resume.
Company: {company}
Profile: {profile}
Job Description: {jd}
Resume (optional): {resume}
Provide questions clearly labeled under each round.
"""
)
llm = ChatOpenAI(temperature=0.7)
chain = LLMChain(llm=llm, prompt=template)
if st.button("Generate Interview Rounds"):
with st.spinner("Generating questions..."):
response = chain.run({
"company": company,
"profile": profile,
"jd": jd,
"resume": resume_text,
})
st.subheader("πŸ“‹ Interview Questions")
st.write(response)