Spaces:
Running
Running
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 | |