Job hunting is already overwhelmingโyou shouldn't have to spend hours writing cover letters too. That's why we created the AI-Powered Cover Letter Generator. It's designed with a simple purpose: to help you create impressive, personalized cover letters in minutes, not hours, so you can focus on what really matters in your job search.
This application takes your existing CV/resume and transforms it into personalized cover letters for any job you're applying to. Here's how it helps your job search:
This application is designed with accessibility in mind, requiring no specialized technical knowledge. The streamlined workflow consists of four efficient steps:
That's it! No complicated settings or technical knowledge required.
# git clone https://github.com/KyushMaske/Groq
# pip install -r requirements.txt
.env
file in project directory with your Groq API key:# GROQ_API_KEY=your_groq_api_key_here
# python cover_letter_generator.py
Environment Setup and Imports
import os from dotenv import load_dotenv from PyPDF2 import PdfReader from groq import Groq from tkinter import Tk from tkinter.filedialog import askopenfilename
API Configuration
load_dotenv() api_key = os.getenv("GROQ_API_KEY") client = Groq(api_key=api_key)
PDF Text Extraction
def extract_text_from_pdf(pdf_file_path): try: reader = PdfReader(pdf_file_path) text = "" for page in reader.pages: text += page.extract_text() return text except Exception as e: return f"Error extracting text from PDF: {str(e)}"
Cover Letter Generation
def generate_cover_letter(cv_text, job_position, company_name): try: prompt = ( f"Based on the following CV, please write a personalized cover letter for the position of {job_position} " f"at {company_name}. The cover letter should be professional, concise, polite and relevant to the role.\n\n" f"CV:\n{cv_text}" ) # Create a request to generate the cover letter messages = [ { "role": "system", "content": "You are an AI that generates personalized professional cover letters.", }, {"role": "user", "content": prompt}, ] response = client.chat.completions.create( messages=messages, model="llama3-8b-8192", temperature=0.7, max_tokens=1024, top_p=1, stop=None, ) cover_letter = response.choices[0].message.content return cover_letter except Exception as e: return f"Error generating cover letter: {str(e)}"
File Saving
def save_cover_letter_as_text(cover_letter, job_position, company_name): file_name = f"{job_position}_Cover_Letter_for_{company_name}.txt" try: with open(file_name, "w") as file: file.write(cover_letter) print(f"\nCover letter successfully saved as {file_name}") except Exception as e: print(f"Error saving cover letter as text: {str(e)}")
Main Execution Flow
def main(): root = Tk() root.withdraw() pdf_path = askopenfilename( filetypes=[("PDF files", "*.pdf")], title="Select your CV in PDF format" ) if not pdf_path: print("No file selected. Exiting.") return cv_text = extract_text_from_pdf(pdf_path) if "Error" in cv_text: print(cv_text) return print("\nExtracted CV Text:\n", cv_text[:1000], "...") job_position = input( "\nEnter the job position you're applying for (e.g., Software Engineer): " ) company_name = input("Enter the company name: ") cover_letter = generate_cover_letter(cv_text, job_position, company_name) if "Error" not in cover_letter: print("\nGenerated Cover Letter:\n") print(cover_letter) save_cover_letter_as_text(cover_letter, job_position, company_name) else: print(cover_letter)
The AI-Powered Cover Letter Generator: Crafting Personalized Letters from Your CV delivers an elegant solution to one of the most resource-intensive components of the professional application process. By harnessing sophisticated language models to analyze your career portfolio and generate targeted application materials, this tool enables candidates to present their qualifications effectively while conserving valuable time for strategic career development activities.
Whether you're pursuing a singular aspirational position or executing a comprehensive employment campaign, this application ensures the consistent quality and personalization necessary for compelling submissions across all opportunities. As employment landscapes continue to evolve, innovations like this exemplify the productive intersection of technological advancement and practical career enhancement.
While the current implementation offers substantial utility, our development roadmap includes several strategic improvements:
Expanded Format Compatibility: Implementation of support for additional document formats including DOCX and TXT to accommodate diverse user preferences
Advanced Customization Parameters: Introduction of granular personalization options to further refine output according to specific industry conventions and individual requirements
Web-Based Interface: Development of a browser-accessible platform to eliminate installation requirements and enhance accessibility across devices
Multilingual Capabilities: Integration of support for multiple languages to serve international employment markets and cross-border career opportunities
These planned enhancements reflect our commitment to continuous improvement and responsiveness to evolving user needs in the dynamic professional landscape.