super template pdf

This commit is contained in:
feder-cr 2024-08-09 19:40:56 +01:00
parent e314cc6ebb
commit ade22dbd68
6 changed files with 23 additions and 43 deletions

10
gpt.py
View File

@ -167,17 +167,19 @@ class GPTAnswerer:
def get_resume_html(self):
resume_markdown_prompt = ChatPromptTemplate.from_template(strings.resume_markdown_template)
fusion_job_description_resume_prompt = ChatPromptTemplate.from_template(strings.fusion_job_description_resume_template)
resume_markdown_chain = resume_markdown_prompt | self.llm_cheap | StrOutputParser()
fusion_job_description_resume_chain = fusion_job_description_resume_prompt | self.llm_cheap | StrOutputParser()
casual_markdown_path = os.path.abspath("resume_template/casual_markdown.js")
reorganize_header_path = os.path.abspath("resume_template/reorganizeHeader.js")
resume_css_path = os.path.abspath("resume_template/resume.css")
#html_template = strings.html_template.format(email_address=self.resume.personal_information.email, phone_number=self.resume.personal_information.phonePrefix + self.resume.personal_information.phone , github_link=self.resume.personal_information.github, linkedin_link=self.resume.personal_information.linkedin,city=self.resume.personal_information.city,country=self.resume.personal_information.country)
html_template = strings.html_template.format(casual_markdown=casual_markdown_path, reorganize_header=reorganize_header_path, resume_css=resume_css_path)
composed_chain = (
resume_markdown_chain
| (lambda output: {"job_description": self.job.summarize_job_description, "formatted_resume": output})
| fusion_job_description_resume_chain
| (lambda formatted_resume: strings.html_template + formatted_resume)
| (lambda formatted_resume: html_template + formatted_resume)
)
try:

View File

@ -87,8 +87,8 @@ class LinkedInEasyApplier:
def _scroll_page(self) -> None:
scrollable_element = self.driver.find_element(By.TAG_NAME, 'html')
# utils.scroll_slow(self.driver, scrollable_element, step=300, reverse=False)
# utils.scroll_slow(self.driver, scrollable_element, step=300, reverse=True)
utils.scroll_slow(self.driver, scrollable_element, step=300, reverse=False)
utils.scroll_slow(self.driver, scrollable_element, step=300, reverse=True)
def _fill_application_form(self):
while True:
@ -195,9 +195,9 @@ class LinkedInEasyApplier:
file_path_pdf = os.path.join(folder_path, file_name_pdf)
with open(file_path_pdf, "wb") as f:
f.write(base64.b64decode(utils.HTML_to_PDF(file_name_HTML,True)))
f.write(base64.b64decode(utils.HTML_to_PDF(file_name_HTML)))
element.send_keys(file_path_pdf)
element.send_keys(os.path.abspath(file_path_pdf))
time.sleep(2) # Give some time for the upload process
os.remove(file_name_HTML)
return True

View File

@ -40,4 +40,4 @@ function reorganizeHeader() {
setTimeout(function() {
reorganizeHeader();
}, 100);
}, 1000);

View File

@ -25,6 +25,12 @@ Provide guidance on how to enhance the presentation of the information to maximi
```
# [Full Name]
[Your City, Your Country](Maps link)
[Your Prefix Phone number](tel: Your Prefix Phone number)
[Your Email](mailto:Your Email)
[LinkedIn](Link LinkedIn account)
[GitHub](Link GitHub account)
## Summary
[Brief professional summary highlighting your experience, key skills, and career objectives. 2-3 sentences.]
@ -38,7 +44,7 @@ Provide guidance on how to enhance the presentation of the information to maximi
- **Skill4:** [details (max 15 word)]
- **Skill5:** [details (max 15 word)]
## Professional Experience
## Working Experience
### [Job Title]
**[Company Name]** [City, State]
@ -126,39 +132,13 @@ html_template = """
<!DOCTYPE html>
<title>Resume</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/casualwriter/casual-markdown/dist/casual-markdown.css">
<script src="https://cdn.jsdelivr.net/gh/casualwriter/casual-markdown/dist/casual-markdown.js"></script>
<style>
body {{ line-height:1.5; margin:auto; padding:3px; max-width:1024px; display:none; FONT-FAMILY:"Segoe UI",ARIAL; }}
h1 {{ font-size:200%; padding:16px; border:1px solid lightgrey; BACKGROUND:#f0f0f0; }}
h2 {{ border-bottom:1px solid grey; padding:2px }}
</style>
<script src="{casual_markdown}"></script>
<script src="{reorganize_header}"></script>
<link rel="stylesheet" href="{resume_css}">
<body onload="document.body.innerHTML=md.html(document.body.innerHTML); document.body.style.display='block';">
<span style="float:right; padding:6px; display:block; text-align: center; width:250px;">
{email_address} <br> {phone_number} <a href="{github_link}" style="color: #0366d6; text-decoration: none;">GitHub</a> - <a href="{linkedin_link}" style="color: #0366d6; text-decoration: none;">LinkedIn</a>
</span>
<span style="
position: fixed;
top: 16.5%;
left: 18%;
transform: translate(-50%, -50%);
padding: 6px;
text-align: center;
z-index: 1000;
">
{city}, {country}
</span>
"""
# Personal Information Template
personal_information_template = """
Answer the following question based on the provided personal information.

View File

@ -51,7 +51,7 @@ def scroll_slow(driver, scrollable_element, start=0, end=3600, step=100, reverse
print(f"Exception occurred: {e}")
def HTML_to_PDF(FilePath, Hide_Window=True):
def HTML_to_PDF(FilePath):
# Validate and prepare file paths
if not os.path.isfile(FilePath):
raise FileNotFoundError(f"The specified file does not exist: {FilePath}")
@ -60,8 +60,6 @@ def HTML_to_PDF(FilePath, Hide_Window=True):
# Set up Chrome options
chrome_options = webdriver.ChromeOptions()
if Hide_Window:
chrome_options.add_argument("--headless") # Run Chrome in headless mode
# Initialize Chrome driver
service = ChromeService(ChromeDriverManager().install())
@ -70,7 +68,7 @@ def HTML_to_PDF(FilePath, Hide_Window=True):
try:
# Load the HTML file
driver.get(FilePath)
time.sleep(3) # Adjust the sleep time if necessary
start_time = time.time()
pdf_base64 = driver.execute_cdp_cmd("Page.printToPDF", {
"printBackground": True, # Incluir los fondos en el PDF