Resume Feedback

Resume Feedback Agent

  1. User will upload resume

  2. Agent 1 will analyze the resume and get tech keys like "python, java, nlp, spacy"

  3. Agent 2 will give resume recommendation for the user resume

  4. Agent 3 will find the better resume from private DB and pick 3 resumes as a recommendation

Here’s an implementation plan using LangChain and OpenAI for your "Resume Feedback Agent." The implementation assumes that you have access to an OpenAI API key and a database of resumes for Agent 3 to search.


Code Implementation

from langchain.prompts import PromptTemplate
from langchain.llms import OpenAI
from langchain.agents import initialize_agent, Tool
from langchain.tools import BaseTool
from langchain.chains import LLMChain

# Agent 1: Extract tech keys from the resume
class TechKeyExtractor(BaseTool):
    name = "tech_key_extractor"
    description = "Extracts technical skills like Python, Java, NLP, etc., from resumes."

    def _run(self, resume: str):
        prompt = PromptTemplate(
            input_variables=["resume"],
            template="""
            Extract technical skills from the following resume:
            Resume: {resume}
            Skills:
            """
        )
        chain = LLMChain(llm=OpenAI(), prompt=prompt)
        return chain.run(resume)

# Agent 2: Provide resume recommendations
class ResumeImprover(BaseTool):
    name = "resume_improver"
    description = "Provides recommendations to improve a resume."

    def _run(self, resume: str):
        prompt = PromptTemplate(
            input_variables=["resume"],
            template="""
            Analyze the given resume and provide specific recommendations for improvement:
            Resume: {resume}
            Recommendations:
            """
        )
        chain = LLMChain(llm=OpenAI(), prompt=prompt)
        return chain.run(resume)

# Agent 3: Find better resumes from a private database
class ResumeRecommender(BaseTool):
    name = "resume_recommender"
    description = "Fetches top 3 better resumes from a private database as recommendations."

    def _run(self, resume: str):
        # Simulate querying a private database
        database = [
            {"id": 1, "resume": "Resume 1: Experienced Python Developer, ML enthusiast, Flask, FastAPI."},
            {"id": 2, "resume": "Resume 2: Java and Spring Boot developer with DevOps skills."},
            {"id": 3, "resume": "Resume 3: NLP researcher, Spacy, and BERT expert."},
            {"id": 4, "resume": "Resume 4: Full-stack engineer with Python, React, and AWS."},
        ]

        # Use LLM to compare resumes
        prompt = PromptTemplate(
            input_variables=["resume", "database"],
            template="""
            Given the following resume:
            {resume}

            And the database of resumes:
            {database}

            Find the 3 resumes that are better than the given resume.
            """
        )
        chain = LLMChain(llm=OpenAI(), prompt=prompt)
        return chain.run({"resume": resume, "database": "\n".join([str(d) for d in database])})

# Integrating tools into a single agent
tools = [
    TechKeyExtractor(),
    ResumeImprover(),
    ResumeRecommender(),
]

# Initializing the multi-tool agent
agent = initialize_agent(tools=tools, llm=OpenAI(), agent="zero-shot-react-description")

# Main function to analyze a user's resume
def analyze_resume(resume_text):
    response = agent.run(f"Analyze the resume: {resume_text}")
    return response

# Example Usage
if __name__ == "__main__":
    user_resume = """
    Software engineer with experience in Python, Java, and machine learning.
    Worked on Flask, FastAPI, and NLP projects using Spacy and NLTK.
    """
    print(analyze_resume(user_resume))

Code Breakdown

  1. Agent 1:

    • Extracts technical skills from the resume using a predefined prompt.

    • Employs OpenAI LLM to list skills like "Python, Java, NLP, Spacy, etc."

  2. Agent 2:

    • Analyzes the resume and provides detailed recommendations for improvement.

    • Uses a prompt tailored to suggest actionable improvements.

  3. Agent 3:

    • Simulates fetching better resumes from a private database.

    • Compares the user's resume against database entries and retrieves the top 3 recommendations.

  4. Integration:

    • Combines all tools into a single LangChain agent (initialize_agent).

    • Runs the entire process using a single user input.


Next Steps

  • Database Integration: Replace the simulated database in Agent 3 with a real private database connection.

  • Optimization: Fine-tune prompts for better performance based on actual resume data.

  • Interface: Build a user-friendly web or CLI interface for uploading resumes.

Last updated