Spaces:
Sleeping
Sleeping
Update Profile_Detail.py
#1
by
AnishaG0201
- opened
- Profile_Detail.py +31 -32
Profile_Detail.py
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
from dotenv import load_dotenv
|
4 |
-
|
5 |
-
from langchain_google_genai import ChatGoogleGenerativeAI
|
6 |
from fpdf import FPDF
|
7 |
-
import fitz
|
8 |
|
9 |
# Load environment variables
|
10 |
load_dotenv()
|
11 |
|
|
|
|
|
12 |
|
13 |
def generate_resume(details):
|
14 |
prompt = f"""
|
15 |
Create an ATS-optimized resume based on the following details:
|
16 |
-
|
17 |
Name: {details['name']}
|
18 |
Contact Information: {details['contact']}
|
19 |
LinkedIn Profile: {details['linkedin']}
|
@@ -23,28 +23,28 @@ def generate_resume(details):
|
|
23 |
Skills: {details['skills']}
|
24 |
Certifications: {details['certifications']}
|
25 |
Projects: {details['projects']}
|
26 |
-
|
27 |
Provide the resume in a well-structured format.
|
28 |
"""
|
29 |
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
|
|
|
33 |
return resume
|
34 |
|
35 |
-
|
36 |
-
|
37 |
def create_pdf(resume_text, filename):
|
38 |
-
|
39 |
-
|
40 |
-
pdf.set_auto_page_break(auto=True, margin=15)
|
41 |
-
pdf.set_font("Arial", size=12)
|
42 |
|
|
|
43 |
for line in resume_text.split('\n'):
|
44 |
-
|
|
|
45 |
|
46 |
-
|
47 |
-
|
48 |
|
49 |
def extract_text_from_pdf(pdf_file):
|
50 |
doc = fitz.open(stream=pdf_file.read(), filetype="pdf")
|
@@ -93,9 +93,6 @@ def parse_extracted_text(text):
|
|
93 |
|
94 |
return details
|
95 |
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
def app():
|
100 |
st.title("Resume Creation")
|
101 |
|
@@ -104,6 +101,8 @@ def app():
|
|
104 |
if uploaded_file:
|
105 |
extracted_text = extract_text_from_pdf(uploaded_file)
|
106 |
details = parse_extracted_text(extracted_text)
|
|
|
|
|
107 |
else:
|
108 |
details = {
|
109 |
'name': "",
|
@@ -117,21 +116,21 @@ def app():
|
|
117 |
'projects': ""
|
118 |
}
|
119 |
|
120 |
-
with st.form("
|
121 |
st.header("Enter your details to generate an ATS-optimized resume")
|
122 |
|
123 |
-
name = st.text_input("Name")
|
124 |
-
contact = st.text_area("Contact Information (phone, email, address)")
|
125 |
-
linkedin = st.text_input("LinkedIn Profile URL")
|
126 |
-
summary = st.text_area("Professional Summary")
|
127 |
-
experience = st.text_area("Work Experience (provide details of each job including company name, job title, duration, and responsibilities)")
|
128 |
-
education = st.text_area("Education (provide details of degrees, institutions, and graduation dates)")
|
129 |
-
skills = st.text_area("Skills (list your skills)")
|
130 |
-
certifications = st.text_area("Certifications (list any relevant certifications)")
|
131 |
-
projects = st.text_area("Projects (provide details of your projects)")
|
132 |
|
133 |
submitted = st.form_submit_button("Generate Resume")
|
134 |
-
|
135 |
if submitted:
|
136 |
if name and contact and linkedin and summary and experience and education and skills and certifications and projects:
|
137 |
details = {
|
@@ -148,10 +147,10 @@ def app():
|
|
148 |
resume = generate_resume(details)
|
149 |
st.header("Generated Resume")
|
150 |
st.text(resume)
|
151 |
-
|
152 |
# Save resume as PDF and provide download link
|
153 |
pdf_filename = "resume.pdf"
|
154 |
-
|
155 |
|
156 |
with open(pdf_filename, "rb") as pdf_file:
|
157 |
st.download_button(
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
from dotenv import load_dotenv
|
4 |
+
import openai
|
|
|
5 |
from fpdf import FPDF
|
6 |
+
import fitz # PyMuPDF
|
7 |
|
8 |
# Load environment variables
|
9 |
load_dotenv()
|
10 |
|
11 |
+
# Set up the OpenAI API key
|
12 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
13 |
|
14 |
def generate_resume(details):
|
15 |
prompt = f"""
|
16 |
Create an ATS-optimized resume based on the following details:
|
|
|
17 |
Name: {details['name']}
|
18 |
Contact Information: {details['contact']}
|
19 |
LinkedIn Profile: {details['linkedin']}
|
|
|
23 |
Skills: {details['skills']}
|
24 |
Certifications: {details['certifications']}
|
25 |
Projects: {details['projects']}
|
|
|
26 |
Provide the resume in a well-structured format.
|
27 |
"""
|
28 |
|
29 |
+
response = openai.Completion.create(
|
30 |
+
engine="text-davinci-003",
|
31 |
+
prompt=prompt,
|
32 |
+
max_tokens=1500
|
33 |
+
)
|
34 |
|
35 |
+
resume = response.choices[0].text.strip()
|
36 |
return resume
|
37 |
|
|
|
|
|
38 |
def create_pdf(resume_text, filename):
|
39 |
+
doc = fitz.open()
|
40 |
+
page = doc.new_page()
|
|
|
|
|
41 |
|
42 |
+
x, y = 72, 72 # Starting position
|
43 |
for line in resume_text.split('\n'):
|
44 |
+
y += 12 # Move to the next line (adjust the spacing as needed)
|
45 |
+
page.insert_text((x, y), line, fontsize=12)
|
46 |
|
47 |
+
doc.save(filename)
|
|
|
48 |
|
49 |
def extract_text_from_pdf(pdf_file):
|
50 |
doc = fitz.open(stream=pdf_file.read(), filetype="pdf")
|
|
|
93 |
|
94 |
return details
|
95 |
|
|
|
|
|
|
|
96 |
def app():
|
97 |
st.title("Resume Creation")
|
98 |
|
|
|
101 |
if uploaded_file:
|
102 |
extracted_text = extract_text_from_pdf(uploaded_file)
|
103 |
details = parse_extracted_text(extracted_text)
|
104 |
+
st.write("Extracted Text:", extracted_text) # Debug: Show the extracted text
|
105 |
+
st.write("Parsed Details:", details) # Debug: Show the parsed details
|
106 |
else:
|
107 |
details = {
|
108 |
'name': "",
|
|
|
116 |
'projects': ""
|
117 |
}
|
118 |
|
119 |
+
with st.form("resume_form"):
|
120 |
st.header("Enter your details to generate an ATS-optimized resume")
|
121 |
|
122 |
+
name = st.text_input("Name", value=details['name'])
|
123 |
+
contact = st.text_area("Contact Information (phone, email, address)", value=details['contact'])
|
124 |
+
linkedin = st.text_input("LinkedIn Profile URL", value=details['linkedin'])
|
125 |
+
summary = st.text_area("Professional Summary", value=details['summary'])
|
126 |
+
experience = st.text_area("Work Experience (provide details of each job including company name, job title, duration, and responsibilities)", value=details['experience'])
|
127 |
+
education = st.text_area("Education (provide details of degrees, institutions, and graduation dates)", value=details['education'])
|
128 |
+
skills = st.text_area("Skills (list your skills)", value=details['skills'])
|
129 |
+
certifications = st.text_area("Certifications (list any relevant certifications)", value=details['certifications'])
|
130 |
+
projects = st.text_area("Projects (provide details of your projects)", value=details['projects'])
|
131 |
|
132 |
submitted = st.form_submit_button("Generate Resume")
|
133 |
+
|
134 |
if submitted:
|
135 |
if name and contact and linkedin and summary and experience and education and skills and certifications and projects:
|
136 |
details = {
|
|
|
147 |
resume = generate_resume(details)
|
148 |
st.header("Generated Resume")
|
149 |
st.text(resume)
|
150 |
+
|
151 |
# Save resume as PDF and provide download link
|
152 |
pdf_filename = "resume.pdf"
|
153 |
+
create_pdf_with_pymupdf(resume, pdf_filename)
|
154 |
|
155 |
with open(pdf_filename, "rb") as pdf_file:
|
156 |
st.download_button(
|