MBilal-72 commited on
Commit
d1ae37d
·
verified ·
1 Parent(s): a0db2ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -5
app.py CHANGED
@@ -4,8 +4,11 @@ import pdfplumber
4
  import docx
5
  from sentence_transformers import SentenceTransformer
6
  import faiss
7
- import numpy as np
8
  from groq import Groq
 
 
 
 
9
 
10
  # -----------------------------
11
  # CONFIG
@@ -72,11 +75,34 @@ def match_jobs(resume_text, jobs, top_k=5):
72
 
73
  def generate_resume(resume_text, job):
74
  prompt = f"""
75
- You are an AI career assistant.
76
  Given this resume:\n{resume_text}\n
77
  and this job description:\n{job['description']}\n
78
- Generate a tailored one-page resume that highlights relevant skills and experience.
79
- Keep it concise and professional.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  """
81
 
82
  chat_completion = groq_client.chat.completions.create(
@@ -86,6 +112,21 @@ def generate_resume(resume_text, job):
86
  )
87
  return chat_completion.choices[0].message.content
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  # -----------------------------
91
  # STREAMLIT UI
@@ -110,4 +151,15 @@ if resume_file:
110
 
111
  if st.button(f"Generate Resume for {job['position']}", key=job['id']):
112
  tailored_resume = generate_resume(resume_text, job)
113
- st.text_area("Tailored Resume", tailored_resume, height=300)
 
 
 
 
 
 
 
 
 
 
 
 
4
  import docx
5
  from sentence_transformers import SentenceTransformer
6
  import faiss
 
7
  from groq import Groq
8
+ from reportlab.lib.pagesizes import A4
9
+ from reportlab.lib.styles import getSampleStyleSheet
10
+ from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
11
+ import io
12
 
13
  # -----------------------------
14
  # CONFIG
 
75
 
76
  def generate_resume(resume_text, job):
77
  prompt = f"""
78
+ You are an AI career assistant.
79
  Given this resume:\n{resume_text}\n
80
  and this job description:\n{job['description']}\n
81
+ Generate a structured resume in this format:
82
+
83
+ Name & Contact
84
+ -----------------
85
+ [Fill with placeholder if not in resume]
86
+
87
+ Summary
88
+ -----------------
89
+ [2-3 line summary tailored for the job]
90
+
91
+ Skills
92
+ -----------------
93
+ - Skill 1
94
+ - Skill 2
95
+ - Skill 3
96
+
97
+ Experience
98
+ -----------------
99
+ Job Title | Company | Dates
100
+ • Achievement 1
101
+ • Achievement 2
102
+
103
+ Education
104
+ -----------------
105
+ Degree | Institution | Year
106
  """
107
 
108
  chat_completion = groq_client.chat.completions.create(
 
112
  )
113
  return chat_completion.choices[0].message.content
114
 
115
+ def build_pdf(resume_text):
116
+ buffer = io.BytesIO()
117
+ doc = SimpleDocTemplate(buffer, pagesize=A4)
118
+ styles = getSampleStyleSheet()
119
+ story = []
120
+
121
+ for line in resume_text.split("\n"):
122
+ if line.strip() == "":
123
+ story.append(Spacer(1, 12))
124
+ else:
125
+ story.append(Paragraph(line, styles["Normal"]))
126
+
127
+ doc.build(story)
128
+ buffer.seek(0)
129
+ return buffer
130
 
131
  # -----------------------------
132
  # STREAMLIT UI
 
151
 
152
  if st.button(f"Generate Resume for {job['position']}", key=job['id']):
153
  tailored_resume = generate_resume(resume_text, job)
154
+
155
+ # Show editable preview
156
+ edited_resume = st.text_area("Tailored Resume", tailored_resume, height=300)
157
+
158
+ # Build PDF
159
+ pdf_buffer = build_pdf(edited_resume)
160
+ st.download_button(
161
+ label="📥 Download Resume (PDF)",
162
+ data=pdf_buffer,
163
+ file_name="tailored_resume.pdf",
164
+ mime="application/pdf",
165
+ )