File size: 7,004 Bytes
19adbe3
 
681778f
19adbe3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e14414b
19adbe3
 
 
 
cf7d72c
 
 
 
 
 
 
 
 
19adbe3
 
 
 
 
 
 
cf7d72c
 
 
 
 
19adbe3
cf7d72c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19adbe3
cf7d72c
 
 
 
 
 
 
 
 
 
19adbe3
cf7d72c
 
 
 
19adbe3
cf7d72c
 
19adbe3
cf7d72c
19adbe3
cf7d72c
 
 
 
 
 
19adbe3
cf7d72c
19adbe3
 
 
 
 
 
 
 
 
e14414b
19adbe3
 
 
 
 
e14414b
19adbe3
 
 
aee933d
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import gradio as gr
from pypdf import PdfReader
from resume_tools import create_resume_agent


def read_pdf_file(file_path):
    """
    Reads text content from a PDF file.

    Args:
        file_path (str): The path to the PDF file.

    Returns:
        str: The extracted text content from the PDF.
    """
    try:
        reader = PdfReader(file_path)
        text = ""
        for page in reader.pages:
            text += page.extract_text() + "\n"  # Add newline between pages
        return text
    except Exception as e:
        return f"Error reading PDF file: {e}"



def process_inputs(resume, job_description, custom_instructions):
    if resume is not None:
        resume = read_pdf_file(resume)
    else:
        return "Please enter a valid PDF File"
    prompt = f"""
    You are an expert Resume Optimization Agent specializing in creating concise, ATS-friendly, single-page resumes tailored strictly to a given Job Description (JD).
    
    Your task is to **align the candidate’s resume with the JD to achieve a high ATS (Applicant Tracking System) score**, while preserving the integrity of the original content.
    
    ---
    
    ###  **Mandatory Tool Usage Sequence:**
    
    1. header_details_tool
    2. professional_summary_tool
    3. Professional_experience
    4. Projects
    5. Skills
    6. Education
    7. Achievements
    
    Each tool must be called in this exact sequence.
    Each tool should return its respective section content, along with an instruction to proceed to the next tool.
    Never skip, combine, or reorder tools.
    
    ---
    
    ###  **Core Instructions:**
    
    1. **Resume Length & Structure:**
       - One page only.
       - Professional Summary: 2–3 lines — introduce tools, technologies, problem-solving ability (no numbers here).
       - Professional Experience: 4–6 bullets for recent role; older roles: 2–3 bullets. Follow Star methods while writing bullet points focussing on quantifying impacts.
       - Projects: Max 2 projects; 2–3 bullets each.
       - Bullet points ≤ 25 words, bullet points should not be very long and not exceed 2 lines.
       - Quantify things in bullet points especially for professional experience.
    
    2. **JD Alignment Rules:**
       - You are allowed to modify **20–30% of the content** of any bullet point to align with the JD.
       - Modifications may include changing keywords, replacing tools/tech names, adjusting domain-specific phrases — **without altering the fundamental meaning** of the original point.
       - Example:
         example 1:- Original: "Built ML models for recommendation systems."
         JD requires Generative AI → Acceptable change:
         "Built \\textbf{{LLMs}} for recommendation systems."
        example 2:- Original: " build applications using react"
        JD Requires Angular, Node JS -> Acceptable change:
        " build applications using Angular, NodeJS"
    
        - Also note when you apply above modifications, ensure that the bullet point has relevant meaning. If suppose the user mentioned some feature in react and you changed it from react to angular, ensure that the same feature is available in angular as well, else you will fail.
         Other example can be, user mentioned that he has utilized LangGraph and created Human-in-loop and now for instance if Job requires one who is good at smolagents framework, dont just change like created Human-in-loop using smolagents since smolagents don't have such feature.
        - So, change meaningfully.
    
    3. **STAR Format Enforcement:**
       - Ensure each bullet follows **Situation, Task, Action, Result (STAR)** format.
       - Include measurable impact wherever possible (time saved, accuracy improved, cost reduced, etc.).
       - While writing bullet points in experience section, try quantifying things.
    
    4. **Keyword Highlighting:**
       - Bold important technologies, tools, and results using: `\\textbf{{...}}` and use double backward slashes as shown.
       - Example:
         "Reduced training time by \\textbf{{40%}} using mixed-precision optimization."
    
    5. **Skills Section Handling:**
       - Include skills/tools from both the candidate’s background and JD — maximize overlap for ATS.
       - Add relevant frameworks (e.g., TensorFlow if PyTorch is mentioned).
       - Clearly organize for ATS readability.
       - As it is not possible to add every skill that user posses, try to add most of the skills from Job Description and few which are relavant. You can skip a few irrelavant skills that are not inline with JD. Maintain the balance, don't try to add a lot or dont try to skip a lot.
    
    6. **Strict Warnings (Must Follow):**
       - **20–30% change per bullet is allowed — not full rewrites.**
       - Never invent or fabricate achievements, titles, or skills not backed by the original resume.
       - Never change job titles.
       - Vary action verbs — do not reuse any verb (e.g., "developed") more than 3 times. Using so will result a very bad ATS score.
       - A good ATS resume will have 450-800 words.
       - If you want to bold something stricly use double slash not single slash i.e., \\textbf{{content to bold}} and not \textbf{{content to bold}}. The reason is that when we use single slash the program is changing it to tab space.
    
    ---
    
    ###  **ATS Score Motivation:**
    
     You are rewarded for producing a resume that:
     Strongly aligns with JD keywords and required skills,
     Maintains authenticity of original experience,
     Uses measurable impact statements,
     Strictly limits changes to 20–30% per bullet,
     Is ATS-optimized and one page.
    
    ---
    
    ###  **Input Provided:**
    
    ####  Job Description:
    {job_description}
    
    ####  Original Resume:
    {resume}
    
    ---
    
    #### User Custom Instructions:
    {custom_instructions}
    
    **Begin by invoking `header_details_tool` and proceed strictly as per tool order. Ensure JD alignment, STAR format, keyword emphasis, and 20–30% content change limit in every applicable section.**
    Do not generate final resume at once — output tool-wise only.
    """
    
    print(prompt)
    return create_resume_agent(prompt)

with gr.Blocks() as demo:
    gr.Markdown("## Enhancv")
    with gr.Row():
        with gr.Column():
            resume = gr.File(label="Upload Resume", file_types=[".pdf"])
            job_description = gr.Textbox(label="Paste Job Description here", lines=5)
            custom_instructions = gr.Textbox(label="Just Instruct how you want it to be......!!!!", lines=5)
            submit_btn = gr.Button("Submit")
        with gr.Column():
            output = gr.Textbox(label="LaTEX Resume File", lines=10)
    submit_btn.click(
        fn=process_inputs,
        inputs=[resume, job_description,custom_instructions],
        outputs=output
    )

if __name__ =="__main__":
    demo.launch(debug= True)