DEV Community

Cover image for Automate Your Cover Letter Writing Process with Lyzr Automata
harshit-lyzr
harshit-lyzr

Posted on

Automate Your Cover Letter Writing Process with Lyzr Automata

In today's competitive job market, standing out from the crowd is crucial when applying for a new position. One way to catch the attention of potential employers is through a well-crafted cover letter that highlights your skills, experiences, and passion for the role and company. However, writing personalized cover letters for each application can be time-consuming and challenging.

To streamline this process, we've developed the Lyzr Personalized Cover Letter Generator, powered by Lyzr Automata. This innovative tool leverages advanced AI models to create customized cover letters tailored to your specific job title, experience level, skills, and the company you're applying to.
Features and Customization

Lyzr.ai

Check out the Lyzr.ai community on Discord – hang out with 331 other members and enjoy free voice and text chat.

favicon discord.com

Using the Lyzr Personalized Cover Letter Generator is simple and intuitive:
Input Job Details: Start by entering your job title, years of experience, skills, and the name of the company you're applying to using the user-friendly interface.
Generate Cover Letter: With a click of a button, our system generates a personalized cover letter based on your input. The generated letter highlights your relevant skills, experiences, and motivations for applying to the specific position and company.
Customization Options: You have the flexibility to tweak the generated cover letter further, ensuring it aligns perfectly with your preferences and the requirements of the job application.

Setting Up the Environment
Imports:

pip install lyzr_automata streamlit
import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
from dotenv import load_dotenv
import os
from prompt import example

load_dotenv()
api = os.getenv("OPENAI_API_KEY")
Enter fullscreen mode Exit fullscreen mode

Imports necessary libraries like streamlit, dotenv, PIL, and custom libraries for Lyzr Automata.
Loads environment variables using load_dotenv (likely containing the OpenAI API key).
load_dotenv() is called to load environment variables from a .env file (likely containing your OpenAI API key).
api = os.getenv("OPENAI_API_KEY") retrieves the API key from the environment variable.

OpenAI Model Configuration:

open_ai_text_completion_model = OpenAIModel(
    api_key=api,
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.2,
        "max_tokens": 1500,
    },
)
Enter fullscreen mode Exit fullscreen mode

Defines an OpenAIModel object using the provided API key.
Sets model parameters including the powerful "gpt-4-turbo-preview" model, temperature, and maximum token limit.

User Input:

title = st.sidebar.text_input("Enter Job Title", placeholder="Python Developer")
experience = st.sidebar.slider("Select your Experience", 0, 30, 2)
skill = st.sidebar.text_input("Enter Your Skills", placeholder="Python,Django,AWS")
company = st.sidebar.text_input("Enter Company Name", placeholder="Google")
Enter fullscreen mode Exit fullscreen mode

Provides text input fields and a slider in the sidebar for users to enter their Job Title, Experience, Skills, and Company Name.

Generating Cover Letter:

def cover_letter(job_title,experience,skills,company_name):

    toxicity_agent = Agent(
            role="Cover Letter expert",
            prompt_persona=f"You are an Expert Cover Letter writer.Your Task Is to create cover letter for given details."
        )

    prompt = f"""Write a cover letter for a job application for {job_title} with {experience} years of experience at {company_name}.Have a experience in {skills} Make sure to highlight technical skills, past experiences, and explain why you're passionate about this role and company.
        Follow Below Instructions:
        1/ Cover letter content is upto 300 words not more than it.
        2/ Do not write about Job Posting or advertised Job
        3/ Keep Cover letter very simple and include all skills which is needed for job title.
        4/ Analyse company on internet and also write something about company.

        Example:
        {example}  
        """

    toxicity_task = Task(
        name="Generate Cover Letter",
        model=open_ai_text_completion_model,
        agent=toxicity_agent,
        instructions=prompt,
    )

    output = LinearSyncPipeline(
        name="Cover Letter Pipline",
        completion_message="Cover Letter Generated!!",
        tasks=[
              toxicity_task
        ],
    ).run()

    answer = output[0]['task_output']

    return answer
Enter fullscreen mode Exit fullscreen mode

Defines a function cover_letter that takes user input as arguments.
Creates a Lyzr Automata Agent with the role of "Cover Letter expert" and a prompt persona describing their task.
Constructs a prompt string containing user details, instructions, and an example cover letter structure.
Creates a Lyzr Automata Task object specifying the OpenAI model, agent, and the prompt for generating the cover letter.
Defines a LinearSyncPipeline to execute the task and retrieve the generated cover letter.
Runs the pipeline and retrieves the task output, which is the generated cover letter content.

Output:
Creates a "Generate Cover Letter" button in the sidebar.
When the button is clicked, the cover_letter function is called with user input.
The generated cover letter text is stored in the solution variable.
Displays the generated cover letter content (solution) as markdown text in the main app area.

try it now: https://lyzr-personalized-cover-letter.streamlit.app/
For more information explore the website: Lyzr

Personalized Cover Letter Generator

Purpose

This app harnesses power of Lyzr Automata to Create Personalized Cover letter. You have to Enter Job title,Experience,Sills and company name and it will generate personalized cover letter for you.

Getting Started

Follow these steps to run the Lyzr Personalized Cover Letter Generator Streamlit App locally:

  1. Install Dependencies:
    pip install -r requirements.txt
    
    Enter fullscreen mode Exit fullscreen mode
  2. Run the App:
    streamlit run app.py
    
    Enter fullscreen mode Exit fullscreen mode

Tweet Blaster App

Application

About Lyzr

Lyzr is the simplest agent framework to help customers build and launch Generative AI apps faster. It is a low-code agent framework that follows an ‘agentic’ way to build LLM apps, contrary to Langchain’s ‘functions and chains’ way and DSPy’s ‘programmatic’ way of building LLM apps. For more information, visit Lyzr website .






Top comments (0)