SomilRastogi commited on
Commit
b77f9d0
Β·
verified Β·
1 Parent(s): 0a48889

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -26
app.py CHANGED
@@ -1,34 +1,70 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Fancy Addition Calculator with Sidebar and Animations
4
- Created on Sat Jul 12 10:49:24 2025
5
- @author: somil
6
- """
7
-
8
  import streamlit as st
9
- import time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
- # Page Config
12
- st.set_page_config(page_title="Addition Calculator for Eveeryoneskjbgk;jasbgkj;asbga", page_icon="βž•", layout="centered")
13
 
14
- # Sidebar for input
15
- st.sidebar.header("Enter Numbers Here")
16
- number1 = st.sidebar.number_input("Enter Number 1", min_value=0, max_value=100, value=12)
17
- number2 = st.sidebar.number_input("Enter Number 2", min_value=0, max_value=100, value=12)
 
 
18
 
19
- # Main title and animation
20
- st.markdown("<h1 style='text-align: center;'>✨ Basic Addition Calculator for Everyone!!!!!✨</h1>", unsafe_allow_html=True)
21
- st.markdown("<h3 style='text-align: center;'>Let’s crunch some numbers βž•βž•</h3>", unsafe_allow_html=True)
 
 
 
 
 
 
 
22
 
23
- # Animation for effect
24
- with st.spinner("Calculating... 🧠"):
25
- time.sleep(1) # Simple delay for effect
 
26
 
27
- # Result
28
- result = number1 + number2
 
29
 
30
- st.success(f"πŸŽ‰ The sum of **{number1}** and **{number2}** is: **{result}**")
 
 
 
 
 
 
31
 
32
- # Footer message
33
- st.markdown("---")
34
- st.markdown("<p style='text-align: center;'>🌟 Hope you have a <b>nice</b> day! 🌈</p>", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
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
+ # It's good practice to load these from a .env file, but for demonstration purposes, we are setting them directly
15
+ os.environ["OPENAI_API_KEY"] = "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" # Replace with your actual OpenAI API key
16
+
17
+
18
+ # User Inputs
19
+ company = st.text_input("Company Name")
20
+ profile = st.text_input("Profile Name")
21
+ jd = st.text_area("Job Description")
22
+ resume_file = st.file_uploader("Upload Resume (Optional)", type=["pdf"])
23
+
24
+ # Extract text from PDF if resume is uploaded
25
+ resume_text = ""
26
+ if resume_file is not None:
27
+ pdf = PdfReader(resume_file)
28
+ for page in pdf.pages:
29
+ resume_text += page.extract_text()
30
 
31
+ # Submit button
32
+ submit = st.button("Generate Interview Questions")
33
 
34
+ if submit:
35
+ if not company or not profile or not jd:
36
+ st.warning("Please fill in all mandatory fields.")
37
+ else:
38
+ # Set up OpenAI LLM
39
+ llm = ChatOpenAI(temperature=0.7, model_name="gpt-4")
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.
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.write(response)