File size: 11,712 Bytes
cf33545
 
 
 
 
87ab18f
cf33545
 
971eb6e
cf33545
38def87
 
fd1094b
cf33545
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
971eb6e
cf33545
971eb6e
 
 
 
cf33545
 
 
 
 
87ab18f
cf33545
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8ea30cd
 
 
 
cf33545
8ea30cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cf33545
 
 
 
 
 
 
 
971eb6e
cf33545
 
971eb6e
 
cf33545
 
16fe511
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
from smolagents import CodeAgent, LiteLLMModel, tool
from pypdf import PdfReader
import google.generativeai as genai
import os
from typing import List
from utils import CURRENT_RESUME_LATEX as LATEX_TEMPLATE 
from utils import CURRENT_RESUME_LATEX
import os
import re
import json
from dotenv import load_dotenv

# load_dotenv(".env")


@tool
def header_details(name: str, mobile_number: str, email_id: str, linkedin_profile_link : str, github_link: str) -> str:
    """
    Generates header details of the person. It will display the name, mobile_number, email_id, linkedin profile and github profile
    
    Args:
        name(str): Name of the candidate
        mobile_number(str): Mobile number of the candidate
        email_id(str): email_id
        linkedin_profile_link(str): Linkedin profile link of the candidate.
        github_link(str): github link of the candidate.
    
    Returns:
        str: Instruction for the next steps
    """

    header_latex = r""" 

            \begin{center}
                \textbf{\Huge \scshape """
    header_latex+= name + r"""} \\ \vspace{1pt}
                \small""" + mobile_number + r""" $|$ \href{mailto:""" + email_id + r"""}{\underline{"""
    header_latex+= email_id + r"""}} $|$ 
                \href{""" + linkedin_profile_link + r"""}{\underline{"""
    header_latex+= r"""linkedin}} $|$
    \href{""" + github_link + r"""}{\underline{"""
    header_latex+=r"""github}}
    \end{center}


    """
    global CURRENT_RESUME_LATEX
    CURRENT_RESUME_LATEX = LATEX_TEMPLATE
    CURRENT_RESUME_LATEX += header_latex
    response_message = "Now call professional_summary_tool"
    return response_message


@tool
def professional_summary(summary: str) -> str:
    """
    Creates a Professional Experience summary section of the candidate. 
    
    Args:
        summary (str): The generated summary should be in less than 4 lines. It should follow the STAR method while generating the summary. It should speak about the experience and the role he is applying for.
        (e.g: Accomplished Gen AI Specialist with expertise in machine learning (ML), deep learning (DL), generative AI, and AI Agents, proficient in end-to end development from design to deployment. Skilled in problem-solving, data structures and algorithms (DSA), strong analytical abilities, and debugging complex systems. Passionate about optimizing ML model performance to deliver efficient, high-impact AI solutions. Adept at leveraging the full AI stack to drive innovation and achieve business objectives in fast-paced, technology-focused environments)
    
    
    Returns:
        str: Instruction for the next steps
    """

    summary_latex = """
    
    \section{Professional Summary}
    """
    summary_latex += rf"""
    {{{summary}}}
    """
    summary_latex = summary_latex.replace("%","\%")
    global CURRENT_RESUME_LATEX
    CURRENT_RESUME_LATEX += summary_latex
    response_message = "Now call the professional_experience_tool"
    return response_message

@tool
def professional_experience(experiences: List[dict]) -> str:
    """
   Creates an Experience section for a user.Processes the user work experiences across different companies and generates a string in latex form which will be used in further steps


    Args:
        experiences (list of dict): A list where each dict contains:
            - company_name (required) (str): Name of the company.
            - place (Optional) (str): Location of the company. If not mentioned in the resume then keep it as empty string "".
            - period (required) (str): Employment duration (e.g., "Jan 2020 - Dec 2022").
            - role (required) (str): Title or designation.
            - bullet_points (required) (list of str): Key achievements/responsibilities. These points must be in ATS friendly format, quantifying things and  following the STAR method(situation, task , action and result)(eg. reduced latency by 5ms, improved accuracy by 50%).

    Returns:
        str: Instruction for the next steps
    """
    Experience_latex = r"""
    
    \section{Professional Experience}
    \resumeSubHeadingListStart
    """
    for exp in experiences:
        company = exp['company_name']
        period  = exp['period']
        place   = exp['place']
        role    = exp['role']
        bullet_points = exp['bullet_points']
        Experience_latex += rf"""
            \resumeSubheading
              {{{role}}}{{{period}}}
              {{{company}}}{{{place}}}
              \resumeItemListStart
              
            """
        for item in bullet_points:
            Experience_latex += rf"""
            \resumeItem{{{item}}}
            """
        Experience_latex += r"""
        \resumeItemListEnd
       
    \resumeSubHeadingListEnd
    """
    Experience_latex = Experience_latex.replace("%","\%")
    global CURRENT_RESUME_LATEX
    CURRENT_RESUME_LATEX += Experience_latex
    response_message = "Now call the projects tool"
    return response_message


@tool
def projects(projects: List[dict]) -> str :
    """
    Creates an projects section for a user. Processes the projects and generates a string in latex form which will be used in further steps

    Args:
        projects (list of dict): A list where each dict contains:
            - project_name (required) (str): Name of the project.
            - tools_used (required)(list[str]): Tools and technologies used in the project (eg Python, Flask, React, PostgreSQL, Docker). It is a list of strings.
            - period (required)(str): Employment duration (e.g., "Jan 2020 - Dec 2022").
            - bullet_points (required) (list of str): Key achievements/responsibilities.These points must be in ATS friendly format, quantifying things and  following the STAR method(situation, task , action and result)(eg. reduced latency by 5ms, improved accuracy by 50%).

    Returns:
        str: Instruction for the next steps
    """
    Projects_latex = r"""
    
    \section{Projects}
    \resumeSubHeadingListStart
    """
    for project in projects:
        project_name = project['project_name']
        period = project['period']
        tools = ", ".join(project['tools_used'])
        bullet_points = project['bullet_points']
        
        Projects_latex += rf"""
        \resumeProjectHeading
            {{\textbf{{{project_name}}} \textit{{| {tools}}}}}{{}}
        \resumeItemListStart"""
        
        for item in bullet_points:
            Projects_latex += rf"""\resumeItem{{{item}}}"""
            
        Projects_latex += r"""\resumeItemListEnd"""
        
    Projects_latex += r"""\resumeSubHeadingListEnd"""
    Projects_latex = Projects_latex.replace("%","\%")
    
    global CURRENT_RESUME_LATEX
    CURRENT_RESUME_LATEX += Projects_latex
    response_message = "Now call the skills tool"
    return response_message

@tool
def Education(education : List[dict]) -> str:
    """
    Generates an Education section for the candidate. It generates a string which will be processed in the further steps.

    Args:
        education (list of dict): A list where each dict contains:
            - Institute (required) (str): Name of the Institute.
            - place (required)(str): Location of the Institute.
            - period (required)(str): Education duration (e.g., "Jan 2020 - Dec 2022").
            - specialization (required) (str): Specialization of education (e.g., "Bachelors in computer science", "Intermediate", "High School")

    Returns:
        str: Instruction for the next steps
    """
    Education_latex = r"""
    
    \section{Education}
    \resumeSubHeadingListStart
    """
    for edu in education:
        institute_name = edu["Institute"]
        place = edu["place"]
        period = edu["period"]
        specialization = edu["specialization"]
        studies = rf"""
        \resumeSubheading
            {{{institute_name}}}{{{place}}}
            {{{specialization}}}{{{period}}}
        """
        Education_latex+=studies
    Education_latex = Education_latex.replace("%","\%")
    global CURRENT_RESUME_LATEX
    CURRENT_RESUME_LATEX += Education_latex
    response_message = "Now call the achievements tool"
    return response_message

@tool
def achievements(achievements : List[str]) -> str:
    """
    Generates an achievements section for the candidate's resume in LaTeX format.

    Args:
        achievements (List[str]): List of achievement strings to be included in the resume

    Returns:
        str: Instruction for the next steps
    """
    achievements_latex = r"""
    
    \section{Achievements}
    \resumeItemListStart"""

    for achievement in achievements:
        achievements_latex += rf"""
        \resumeItem{{{achievement}}}"""
        
    achievements_latex += r"""
    \resumeItemListEnd

    \end{document}
    """
    achievements_latex = achievements_latex.replace("%","\%")
    global CURRENT_RESUME_LATEX
    CURRENT_RESUME_LATEX += achievements_latex
    response_message = "Created a file in your pc"
    return response_message

@tool
def skills(Programming_languages : List[str], Technologies : List[str], other_skills: dict) -> str:
    """
    Generates an technical skills section for the candidate.It includes programming langugage the candidate is aware of, frameworks, developer tools, technologies. It generates a string which will be processed in the further steps.

    Args:
        Programming_languages (list of strings): contains a list of all the programming languages the candidate is aware of and the new job is expecting. (eg. Python,java,js, HTML, CSS)
        Technologies (list of strings): contains a list of all the technologies which are relevant to the Job description as well as the technologies which the candidate is aware of.
        other_skills (dict): Contains a list of keyworded arguments specifying more about the skills. Each key is the heading like ML Framworks, Developer tools,etc and the values are a list of strings containing the details. Here is an example (eg. kwargs = {"Frameworks": ["React", "Node.js", "Express.js", "UIKit", "SwiftUI", ".NET Core"],"ML Frameworks & tools":[ TensorFlow, PyTorch, Hugging Face, LangChain, Llama Index, JAX, ML Flow, Chroma DB, CrewAI, Numpy,Databricks, Pandas, Hadoop, Pyspark, scikit-learn]})
    Returns:
        str: Instruction for the next steps
    """

    skills_latex = r"""

    \section{Technical Skills}
    \begin{itemize}[leftmargin=0.15in, label={}]
        \small{\item{
            \textbf{Languages}{: """ + ", ".join(Programming_languages) + r"""} \\
            \textbf{Technologies}{: """ + ", ".join(Technologies) + r"""}
            """

    for category, items in other_skills.items():
        skills_latex += rf""" \\
            \textbf{{{category}}}{{{": " + ", ".join(items)}}}
            """

    skills_latex += r"""
        }}
    \end{itemize}
    """
    global CURRENT_RESUME_LATEX
    CURRENT_RESUME_LATEX += skills_latex
    response_message = "Now call the achievements_latex"
    return response_message

    
def create_resume_agent(prompt: str): 
    try:
        model = LiteLLMModel(model_id="gemini/gemini-2.0-flash-exp",
                        api_key=os.getenv("GOOGLE_API_KEY"))
        resume_agent =CodeAgent(
        tools = [header_details,professional_summary,professional_experience,projects,skills,Education,achievements],
        model = model
        )
        # print(resume_agent)
        resume_agent.run(prompt)
        global CURRENT_RESUME_LATEX
        # print(CURRENT_RESUME_LATEX)
        CURRENT_RESUME_LATEX = re.sub(r'\bextbf\s*{(.*?)}', r'\\textbf{\1}', CURRENT_RESUME_LATEX)
        return CURRENT_RESUME_LATEX
    except Exception as e:
        return e