File size: 10,149 Bytes
f8a0c51
 
02cfbd9
 
f8a0c51
 
 
 
 
 
 
dcb67c2
f8a0c51
eacbd9b
98d2c56
f8a0c51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
from pdfminer.high_level import extract_text_to_fp
from io import BytesIO
from Ars.objects import ai,ResumeData,AutomationRiskResult,AutomationRiskInput,RealWorldQuestion,SkillDepthResult,SkillDepthInput,BreakDownByDomainUpdate,FlaggedRiskAreasUpdate,BoostSuggestionsUpdate,AICollabReadinessInput
from Ars.embedDoc import search_pinecone_text
from fastapi import UploadFile
def extract_text_from_bytes(pdf_bytes: bytes) -> str:
    output_string = BytesIO()
    with BytesIO(pdf_bytes) as input_stream:
        extract_text_to_fp(input_stream, output_string)
    return output_string.getvalue().decode()


            
async def resume_analysis(contents) -> ResumeData:
    
    resume = extract_text_from_bytes(pdf_bytes=contents)
    if resume:
        prompt = f"""
        You are an AI resume parser. Read the following resume and extract the following structured information from the resume below if any was found:

        1. Work experience details: job titles and descriptions.(max3)
        2. List of technical skills (technologies, tools, platforms, etc.).(max4)
        3. Soft and transferable skills: 
            - Leadership and collaboration
            - Critical thinking and problem-solving
            - Communication skills
            - Cross-functional/interdisciplinary experience
            - Initiative and adaptability
        4. Career path details:
            - Current or intended role/field
            - Industry and sector context
            - Career trajectory trends
        5. Project experience (if any): project titles, descriptions, role.(max3)
        6. Evidence of upskilling (optional): certifications, courses, learning projects, hackathons.

        Return the extracted data as a JSON object that matches this schema:

        Here is the resume:

        {resume}
        """
        result =ai.chat(prompt=prompt,output_schema=ResumeData)
        return result





def calculate_automation_risk(resume:ResumeData):
    def generate_real_world_data(resume:ResumeData):
        prompt=f"Generata a search query using the resume details below I want to check some text that has data on future jobs reports using semantic searches  Here is the resume data: {resume} "
        result = ai.chat(prompt=prompt,output_schema=RealWorldQuestion)
        search_result =search_pinecone_text(query_text=result.question)

        return search_result

    real_world_data=generate_real_world_data(resume=resume)
    prompt = f"""
    You are an Automation Risk Calculator AI. Your task is to analyze the user's resume and any provided real-world data to estimate how automatable their skills and job titles are.

    For each of the following factors, please evaluate on a scale from 0 to 5, where:

    0 = Not present or irrelevant  
    1 = Very low presence or impact  
    2 = Low presence or impact  
    3 = Moderate presence or impact  
    4 = High presence or impact  
    5 = Very high presence or impact

    Factors to score:

    - repetitiveness of tasks  
    - creativity required  
    - emotional intelligence needed  
    - reliance on data-driven tasks  
    - physical/manual work involved  
    - level of autonomous decision-making  
    - need for strategic thinking  
    - importance of collaboration  
    - current use of AI tools in the role  
    - recent upskilling or adaptability  

    The real-world data may contain labor market trends, automation probabilities, or other relevant insights — use it if helpful.

    After scoring all factors, calculate an overall automation risk score between 0 and 100, where:  
    - 100 means very low automation risk (skills are highly resilient to automation),  
    - 0 means very high automation risk (skills are highly automatable).

    Return only the final integer risk score (0 to 100) — no explanations or extra text.

    Here is the resume:

    (
    {resume}
    )

    Here is the real-world data:

    (
    {real_world_data}
    )
    """
    result = ai.chat(prompt=prompt, output_schema=AutomationRiskInput)
    return result



def calculate_skill_depth(resume:ResumeData):


    prompt = f"""
You are a Skill Depth Calculator AI. Your task is to analyze the user's resume data and score various skill-related factors.

For each of the following factors, please score on a scale from 0 to 5, where:

0 = Not present or no depth  
1 = Very shallow experience or presence  
2 = Basic or limited experience  
3 = Moderate experience or involvement  
4 = Strong experience or senior level  
5 = Expert or highly advanced experience  

Factors to score include (but are not limited to):

- Years of experience per skill  
- Seniority level in roles held  
- Number and relevance of certifications  
- Breadth of skills (variety and diversity)  
- Depth in core technical skills  
- Depth in leadership or management skills  
- Involvement in complex projects  
- Contributions to strategic initiatives  
- Frequency of skill usage in recent roles  
- Evidence of continuous learning or upskilling  
- Cross-functional collaboration skills  
- Recognition or awards related to skills  
- Public speaking or training experience  
- Publications or patents (if any)  
- Industry-specific expertise depth  
- Mentoring or coaching experience  
- Ability to innovate using skills  
- Adaptability to new technologies  
- Problem-solving skills depth  
- Communication skills related to technical content  



Here is the resume:

(
{resume}
)
"""

    result=ai.chat(prompt=prompt,output_schema=SkillDepthInput)
    return result



def calculate_Ai_collab_readiness(resume:ResumeData):


    prompt = f"""
You are an AI Collaboration Readiness Calculator. Your task is to read the following resume and assess how ready the individual is to **collaborate with AI tools**, not just compete against them.

Score the user on the following 10 readiness traits, each on a scale from 0 to 5:

0 = Not mentioned or no evidence  
1 = Very minimal evidence or weak relevance  
2 = Some mention, limited depth  
3 = Moderate use or awareness  
4 = Strong use or understanding  
5 = Expert use or deep integration

Traits to evaluate:

- Mention of AI tools (e.g., ChatGPT, GitHub Copilot, Midjourney, etc.)
- Adaptability to AI-enhanced workflows
- Willingness to learn and adopt AI tools
- Understanding of AI ethics and responsible use
- Demonstrated collaboration with AI (not just use)
- Use of AI for problem-solving
- Creativity in applying AI to new tasks or contexts
- Speed in learning and applying new AI technologies
- Communication skills related to explaining or using AI
- Integration of AI into work/study processes


Here is the resume:

(
{resume}
)
"""

    result=ai.chat(prompt=prompt,output_schema=AICollabReadinessInput)
    return result






def generate_domain_breakdown(resume:ResumeData,**helpful_key_data):


    prompt = f"""
You have one clear objective: analyze the following resume and produce a domain skills breakdown based on the taxonomy below.

**Task:**  
Classify and score the candidate’s skills/domains on a scale from 0 to 100, where 0 means no proficiency and 100 means expert-level proficiency.

**Example output format:**  
- Technical: 65  
- Creative: 80  
- Strategy: 75  
- Collaboration: 60

**Domains to consider (but not limited to):**  
- Technical (e.g., software development, programming)  
- Creative (e.g., design, content creation)  
- Strategy (e.g., planning, business analysis)  
- Collaboration (e.g., teamwork, communication)  

**Requirements:**  
- Return only the domain names and their scores as shown in the example.  
- Scores must be integers between 0 and 100.  
- Provide 4–6 domain categories relevant to the resume content.  
- Use your best judgment based on the resume to assign scores reflecting demonstrated skills and experience.

Here is the resume to analyze:

({resume})


**Analysis data to aid  evaluation**:
**{helpful_key_data}**
"""

    result=ai.chat(prompt=prompt,output_schema=BreakDownByDomainUpdate)
    return result





def generate_flagged_risk_areas(resume:ResumeData,**helpful_key_data):


    prompt = f"""

**You are an AI Resume Risk Evaluator.**
Your job is to review the following resume and flag potential *career resilience risks*. Focus strictly on:

1. **Missing recent/up-to-date certifications**
2. **Lack of AI or automation tool usage**
3. **Dependence on easily automatable tasks** (e.g., repetitive data entry, basic spreadsheets)

For each issue identified, return **a concise 1–2 sentence explanation** with clear language.

**Response Format (Examples)**:

* "Heavy reliance on spreadsheet tasks, which are easily automated."
* "No evidence of recent certifications to stay current in the field."
* "Resume lacks any mention of AI or automation tools."

**Resume to evaluate**:

```
({resume})  
```

**Analysis data to aid  evaluation**:
**{helpful_key_data}**

"""
    result=ai.chat(prompt=prompt,output_schema=FlaggedRiskAreasUpdate)
    return result




def generate_boost_suggestion(resume:ResumeData,**helpful_key_data):


    prompt = f"""
You are a Resume Enhancement AI. Analyze the resume below and generate 2 to 4 clear, actionable suggestions to help the user strengthen their profile by addressing skill or experience gaps.

Focus on practical, AI-driven improvements such as:
- Mastering relevant AI tools
- Enrolling in advanced or specialized courses
- Expanding the complexity or impact of projects
- Obtaining up-to-date certifications

**Examples**:
- "Learn ChatGPT to boost your coding efficiency."
- "Enhance your Python skills through an advanced course."
- "Add recent certifications to demonstrate continuous growth."
- "Integrate AI tools into your project portfolio."

**Guidelines**:
- Suggestions must be specific, relevant, and directly tied to the resume content.
- Keep each suggestion concise (1–2 sentences).
- Avoid generic advice; prioritize actionable, targeted improvements.

Resume to analyze:

({resume})
**Analysis data to aid  evaluation**:
**{helpful_key_data}**
"""

    result=ai.chat(prompt=prompt,output_schema=BoostSuggestionsUpdate)
    return result