YOUYOGITA commited on
Commit
74fbb57
Β·
verified Β·
1 Parent(s): 9e6f984

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -12
app.py CHANGED
@@ -1,19 +1,71 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """
4
- Created on Sun Jul 13 00:02:29 2025
 
 
5
 
6
- @author: yogita
7
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- import streamlit as st
 
10
 
11
- st.title('Basic Addition Calculator')
 
 
 
 
 
12
 
13
- number1 = st.number_input("Enter Number 1", min_value=0, max_value=100, value=12)
14
- number2 = st.number_input("Enter Number 2", min_value=0, max_value=100, value=12)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
 
 
 
 
 
 
 
16
 
17
- number3 = number1 + number2
 
18
 
19
- st.markdown(number3)
 
1
+ import streamlit as st
2
+ from langchain.chat_models import ChatOpenAI
3
+ from langchain.prompts import PromptTemplate
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("πŸ€– AI-Powered Job Interview Preparation")
11
+
12
+ # Secure input for OpenAI API Key
13
+ openai_key = st.text_input("πŸ” Enter your OpenAI API Key", type="password")
14
+
15
+ # User Inputs
16
+ company = st.text_input("🏒 Company Name")
17
+ profile = st.text_input("πŸ’Ό Profile Name")
18
+ jd = st.text_area("πŸ“„ Job Description")
19
+ resume_file = st.file_uploader("πŸ“Ž Upload Resume (Optional)", type=["pdf"])
20
+
21
+ # Extract text from PDF if resume is uploaded
22
+ resume_text = ""
23
+ if resume_file is not None:
24
+ pdf = PdfReader(resume_file)
25
+ for page in pdf.pages:
26
+ resume_text += page.extract_text() or ""
27
 
28
+ # Submit button
29
+ submit = st.button("πŸš€ Generate Interview Questions")
30
 
31
+ if submit:
32
+ if not openai_key or not company or not profile or not jd:
33
+ st.warning("Please fill in all required fields including the OpenAI API Key.")
34
+ else:
35
+ # Set environment variable for OpenAI
36
+ os.environ["OPENAI_API_KEY"] = openai_key
37
 
38
+ # Set up OpenAI LLM
39
+ llm = ChatOpenAI(temperature=0.7, model_name="gpt-4", openai_api_key=openai_key)
40
+
41
+ # Prompt Template
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 (if provided): {resume}
51
+
52
+ Generate a structured set of interview questions:
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
+ chain = LLMChain(llm=llm, prompt=base_prompt)
62
+ response = chain.run({
63
+ "company": company,
64
+ "profile": profile,
65
+ "jd": jd,
66
+ "resume": resume_text or "Not Provided"
67
+ })
68
 
69
+ st.subheader("πŸ“Œ Suggested Interview Questions")
70
+ st.markdown(response)
71