4 readsNo License

AI-Powered Cover Letter Generator: Crafting Personalized Letters from Your CV

Table of contents

AI-Powered Cover Letter Generator: Crafting Personalized Letters from Your CV

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.

What This Tool Does For You

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:

  • Saves Precious Time: Generate tailored cover letters in seconds instead of spending hours writing them from scratch.
  • Personalizes Each Application: Creates unique content that highlights your relevant experience for each specific job.
  • Reduces Application Stress: Simplifies one of the most time-consuming parts of job hunting.
  • Maintains Consistency: Ensures your applications always look professional and polished.
  • Adapts To Any Role: Works for any industry or position.

User-Friendly Application Process

This application is designed with accessibility in mind, requiring no specialized technical knowledge. The streamlined workflow consists of four efficient steps:

  1. Document Selection: Upload your existing PDF resume through the file selection dialog.
  2. Position Specification: Enter the target job title and organization name.
    3.Content Generation: The system processes your information and generates a tailored document.
    4.File Acquisition: Your personalized cover letter is automatically saved as a .txt file with appropriate naming convention.

That's it! No complicated settings or technical knowledge required.

A Peek At The Code

Technology Used

  • Python: Core programming language version 3.6+.
  • PyPDF2: Library for PDF text extraction.
  • Groq API: LLM service provider for AI text generation.
  • LLaMA 3 (8b-8192): Large language model for generating high-quality cover letters.
  • Tkinter: Simple GUI for file selection.
  • dotenv: For secure API key management.

Setup

  1. Clone the repo
# git clone https://github.com/KyushMaske/Groq
  1. Install the required dependencies:
# pip install -r requirements.txt
  1. Create a .env file in project directory with your Groq API key:
# GROQ_API_KEY=your_groq_api_key_here
  1. Run the application
# python cover_letter_generator.py
  1. Select your CV/resume PDF file
  2. Enter the job position you're applying for and company name.
  3. Find the cover ltter text file in directory.

Code Structure.

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)

Wrapping It Up

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.

Future Enhancements

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.