notes73 commited on
Commit
4b44645
Β·
1 Parent(s): 6664933

Updated app.py with full features

Browse files
Files changed (1) hide show
  1. app.py +35 -13
app.py CHANGED
@@ -25,8 +25,8 @@ def analyze_resume(resume_text, job_description):
25
  response = client.chat.completions.create(
26
  model="gpt-4",
27
  messages=[
28
- {"role": "system", "content": "You are a professional resume and job application assistant."},
29
- {"role": "user", "content": f"Analyze this resume:\n{resume_text}\n\nFor the job description:\n{job_description}\n\nProvide keyword optimizations, strengths, and weaknesses."}
30
  ],
31
  temperature=0.7
32
  )
@@ -37,20 +37,35 @@ def generate_cover_letter(resume_text, job_description):
37
  response = client.chat.completions.create(
38
  model="gpt-4",
39
  messages=[
40
- {"role": "system", "content": "You are an expert in writing professional cover letters."},
41
- {"role": "user", "content": f"Generate a personalized cover letter based on this resume:\n{resume_text}\n\nFor the job description:\n{job_description}"}
 
 
 
 
 
 
 
 
 
 
 
 
42
  ],
43
  temperature=0.7
44
  )
45
  return response.choices[0].message.content
46
 
47
  # Streamlit UI
48
- st.title("AI-Powered Job Application Assistant")
49
- st.write("Upload your resume and provide a job description to get AI-powered suggestions.")
50
 
51
- # File uploader
52
- uploaded_file = st.file_uploader("Upload your resume (PDF or DOCX)", type=["pdf", "docx"])
53
- job_description = st.text_area("Paste the job description here")
 
 
 
54
 
55
  if uploaded_file is not None and job_description:
56
  file_extension = uploaded_file.name.split(".")[-1].lower()
@@ -60,16 +75,23 @@ if uploaded_file is not None and job_description:
60
  elif file_extension == "docx":
61
  resume_text = extract_text_from_docx(uploaded_file)
62
  else:
63
- st.error("Unsupported file format")
64
  resume_text = ""
65
 
66
  if resume_text:
67
- st.subheader("Resume Analysis & Optimization")
 
68
  analysis = analyze_resume(resume_text, job_description)
69
  st.write(analysis)
70
 
71
- st.subheader("Generated Cover Letter")
 
72
  cover_letter = generate_cover_letter(resume_text, job_description)
73
  st.write(cover_letter)
74
  else:
75
- st.error("Could not extract text from the uploaded file.")
 
 
 
 
 
 
25
  response = client.chat.completions.create(
26
  model="gpt-4",
27
  messages=[
28
+ {"role": "system", "content": "You are a professional job application assistant. Analyze resumes for strengths, weaknesses, and keyword optimization."},
29
+ {"role": "user", "content": f"Analyze this resume:\n{resume_text}\n\nFor this job description:\n{job_description}\n\nProvide improvements, missing skills, and keyword suggestions."}
30
  ],
31
  temperature=0.7
32
  )
 
37
  response = client.chat.completions.create(
38
  model="gpt-4",
39
  messages=[
40
+ {"role": "system", "content": "You are an expert in writing professional and tailored cover letters."},
41
+ {"role": "user", "content": f"Write a compelling cover letter using this resume:\n{resume_text}\n\nFor the job description:\n{job_description}"}
42
+ ],
43
+ temperature=0.7
44
+ )
45
+ return response.choices[0].message.content
46
+
47
+ # Function to analyze LinkedIn profile
48
+ def analyze_linkedin_profile(profile_text):
49
+ response = client.chat.completions.create(
50
+ model="gpt-4",
51
+ messages=[
52
+ {"role": "system", "content": "You are an expert in LinkedIn profile optimization."},
53
+ {"role": "user", "content": f"Analyze this LinkedIn profile:\n{profile_text}\n\nProvide suggestions for better visibility, keyword optimization, and professionalism."}
54
  ],
55
  temperature=0.7
56
  )
57
  return response.choices[0].message.content
58
 
59
  # Streamlit UI
60
+ st.title("πŸš€ AI-Powered Job Application Assistant")
61
+ st.write("Upload your resume, paste your job description, or enter your LinkedIn profile to get AI-powered insights!")
62
 
63
+ # File uploader for resume
64
+ uploaded_file = st.file_uploader("πŸ“„ Upload your resume (PDF or DOCX)", type=["pdf", "docx"])
65
+ job_description = st.text_area("πŸ“ Paste the job description here")
66
+
67
+ # LinkedIn Profile Analysis
68
+ linkedin_profile = st.text_area("πŸ”— Paste your LinkedIn profile content (optional)")
69
 
70
  if uploaded_file is not None and job_description:
71
  file_extension = uploaded_file.name.split(".")[-1].lower()
 
75
  elif file_extension == "docx":
76
  resume_text = extract_text_from_docx(uploaded_file)
77
  else:
78
+ st.error("❌ Unsupported file format")
79
  resume_text = ""
80
 
81
  if resume_text:
82
+ # Resume Analysis
83
+ st.subheader("πŸ“Š Resume Analysis & Optimization")
84
  analysis = analyze_resume(resume_text, job_description)
85
  st.write(analysis)
86
 
87
+ # Cover Letter Generation
88
+ st.subheader("✍️ Generated Cover Letter")
89
  cover_letter = generate_cover_letter(resume_text, job_description)
90
  st.write(cover_letter)
91
  else:
92
+ st.error("⚠️ Could not extract text from the uploaded file.")
93
+
94
+ if linkedin_profile:
95
+ st.subheader("πŸ” LinkedIn Profile Analysis")
96
+ linkedin_analysis = analyze_linkedin_profile(linkedin_profile)
97
+ st.write(linkedin_analysis)