Behind the code: Creating an AI-Powered Cover Letter & CV Review Web App with Streamlit and OpenAI

Sebastian Carmona A.
8 min readApr 30, 2024

--

Step inside the development process of our AI-driven web app and see how we use Streamlit and OpenAI’s API to craft custom cover letters and optimize CVs.
Authors: Sebastian Carmona, Ayush Sharma, Rachita Raghavendra

Photo by Glenn Carstens-Peters on Unsplash

Check it HERE!

Nowadays, with the number of layoffs occurring, many people are searching for a job; if you go to any open job on LinkedIn, you will find that it has “over 100 applicants.” You need to stand out from all those applicants, and how will you do it? With a tailored CV and a cover letter that shows how your experience aligns with the open role.

According to Novoresume, many employers still expect or prefer applicants to include a cover letter, even if it’s not explicitly required. Failing to provide one when expected could be seen as a lack of effort and interest.

However, according to Rachel Wells at Forbes, some employers and recruiters admit they don’t always read cover letters, especially when dealing with a high volume of applications. In these cases, a well-crafted resume may be more critical.

Cover letters are precious when you need to explain gaps in employment, career changes, or make a case for how your experience translates to the role. They allow you to address potential concerns upfront. For roles where you are highly qualified or have a personal connection at the company, a thoughtful cover letter highlighting your fit can help you stand out.

Choosing the Technology Stack

Why Streamlit?

Streamlit is an excellent choice for building a Python web application due to its simplicity and efficiency. It’s designed to help data scientists create web apps quickly and easily without the need for extensive web development knowledge. With Streamlit, you can turn scripts into shareable web apps in just a few lines of code. It also has built-in support for visualizing data, which makes it a perfect fit for our AI-driven web application.

The Role of OpenAI API

We decided to apply a large language model since we wanted to create a web app that uses a job description and the user's resume in PDF format to tailor the perfect cover letter for the open role.

We tried Google Gemini and ChatGPT 4 first on their respective web applications. We uploaded a resume, added a job description, and generated a prompt for the agent to create a cover letter. After tailoring the perfect prompt and analyzing each output, we used GPT; we needed the OpenAI API.

OpenAI API was the selected Large Language model for the application; it helped us tailor and develop a cover letter and resume reviews based on a job description and a shared resume, precisely as we intended to achieve with our web application.

LangChain

LangChain was the final component we needed. How would we use the OpenAI API to develop this web application without a framework?

LangChain is a framework designed to simplify the creation of applications using LLMs. It provides a set of abstractions and tools for building applications powered by LLMs, covering various stages of the development lifecycle, including data integration, model integration, and development.

Architectural Overview

Designing the Web App

We needed to design our web application since we already knew the tools we would use. How are we distributing the web app? Are we doing this on a single page within page tabs? Do we do a multiple-page web app?

These questions surged as we found that we wanted to add a Classification Machine Learning model to the web application that helps the user classify their job as fake or real.

Now, we had three components:

  • Classification Machine Learning model
  • Cover Letter Generator
  • Resume reviewer

We decided to have a multi-page web application:

  1. Resume Reviewer
Image by Author — Resume Reviewer

This page will ask the user for their resume and all the job information in PDF format. With this information, the LLM Agent will generate a series of points on how the user should tailor their resume and, in the end, a small example of what to include in it.

2. Cover Letter Generator

Image by Author — Cover Letter Generator and Job Classifier

This page asks the user for all the job descriptions and will have two options:

  • Generate the cover letter
  • Classify the job posting; if it is real, it will let you continue to generate the cover letter; if it is fake, it will warn the user about this.

Architecture

  1. Resume Reviewer
Image by Author — Resume Reviewer Architecture

2. Cover Letter Generator and Job Classification

Image by Author — Cover Letter Generator and Job Classification Architecture

3. Cover Letter Generator

Image by Author — Cover Letter Generator

Developing the Core Features

Now, let's talk about code!

We need to understand LangChain, Prompt tailoring, and Streamlit for this. These are our key components in the application. We developed the UI using Streamlit components, LangChain as our LLM framework, and the way to utilize GPT for the cover letter generator. Lastly, we needed to tailor the prompts to get the desired output. Remember, the prompt is the key to success; the prompt is the instructions to the agent (GPT) of what we need.

Utilities

Since we are developing a multi-page application, we needed to create a “utilities” script that saves all the functions we use in the main UI pages.

Under this script, we have different Python functions:

  1. Extract a PDF text

The following function extracts the PDF text so the LLM agent can read and use it.

2. Generate the cover letter (which is also used for the resume reviewer)

This function is divided into three parts:

  • Agent

This function is called the Large Language Model, which we use as our agent. We used the gpt-4-turbo model, the latest OpenAI model trained with data until Dec. 2023.

It also calls the temperature, which is how creative the output will be. The temperature parameter goes from 0 to 2. Lower values for temperature result in more consistent outputs (e.g., 0.2), while higher values generate more diverse and creative results (e.g., 1.0). We decided to go with 0.9 since the default temperature is 0.7, and we wanted a little more creative output.

  • Agent Invoker

This function utilizes the prompts we tailored for the agent to develop our request.

  • Finally, it generates the response output.

Prompts

We have three prompt templates for this web application: 2 for the cover generator and 1 for the resume reviewer.

A prompt is crucial when using GPT or any LLM because it provides instructions and context, guiding it to generate the desired output. A well-crafted prompt can significantly improve the quality and relevance of the model’s response.

  1. Classic Cover Letter

Under this prompt, we decided to give context by giving the agent a role as a professional technical recruiter and the instructions on writing a polished cover letter with no more than three paragraphs employing a business casual tone emphasizing the user's alignment with the job description.

2. Modern Cover Letter

We used the same role as the Classic Cover letter. Still, the difference is that the modern cover letter is only one paragraph long, concise, and more friendly, emphasizing the candidate's resume and the job's key aspects.

3. Resume Reviewer

We continued in our role as professional technical recruiters. Still, the idea and instructions guided the LLM in understanding the job listing and the candidate's resume and analyzing how to improve it to tailor it specifically for the job listing. Finally, it will give an example of a resume.

CV Analysis and Feedback Generation

Since the UI was developed using Streamlit, we used the text_input feature to let the user add everything about the open role. This means adding the Job Title, Job Description, Company, Location, and Company Description. We also used the file_uploader feature so the user could upload their resume in PDF format.

With this information and the resume, the application will ask the user for an Open AI API Key and then Submit the request.

Image by Author — Output of Resume Reviewer

Automating Cover Letter Generator

Like the first page “CV Analysis and Feedback Generation”, we used the same “text_input” future for the user to complete. In this case, we divided the page into two tabs:

  1. Verify and Generate a Cover Letter
Image by Author — Verifying and cover letter generator

In this tab, we applied the Classification Machine Learning Model (we used a Logistic Regression), which, using the data above, allowed us to classify the job as Real or Fake. As soon as the job is classified as real, the user will be asked to insert their resume and the type of cover letter they would like to generate, Modern or Classic. Depending on the user's selection, the prompt used on the agent will be selected.

After selecting the type of cover letter, it will ask the user for the Open AI API Key, and then it can submit the request.

Image by Author — Cover Letter Output
  1. Just Generate the Cover Letter
Image by Author — Cover Letter Generator

This tab jumps to the Machine Learning model and goes straight to asking the user for their resume in PDF, selecting the type of cover letter and the Open AI API Key.

The output will be the generated cover letter the user selects based on the job description and the resume.

Photo by Kelly Sikkema on Unsplash

This helps you develop your first LLM project!

To check the full project code, please visit our project GitHub Repository.

We hope you enjoy it!

--

--

Sebastian Carmona A.
Sebastian Carmona A.

Written by Sebastian Carmona A.

I like coffee and Data, Data and Coffee, simple! OH! And Python, and SQL! www.sebascarmona.com

No responses yet