skjaini commited on
Commit
3e6c9a6
·
verified ·
1 Parent(s): eb02af9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -19
app.py CHANGED
@@ -1,13 +1,13 @@
1
  import streamlit as st
2
  from crewai import Agent, Task, Crew, Process
3
- from langchain_google_genai import ChatGoogleGenerativeAI # Import ChatGoogleGenerativeAI
4
  import os
5
  import fitz # PyMuPDF for PDF handling
6
  import tempfile
7
  from dotenv import load_dotenv
8
  import textwrap
9
 
10
- # Load environment variables (API Keys, etc.)
11
  load_dotenv()
12
 
13
  # --- Helper Functions ---
@@ -38,50 +38,50 @@ def wrap_text(text, width=80):
38
  def create_crew(job_description, resume_text):
39
  """Creates the CrewAI crew with agents and tasks."""
40
 
41
- # Gemini LLM configuration using ChatGoogleGenerativeAI
42
  llm = ChatGoogleGenerativeAI(
43
  model="gemini-1.5-flash-002", # Specify the Gemini 1.5 Flash model
44
  google_api_key=os.environ.get("GOOGLE_API_KEY"), # Use GOOGLE_API_KEY
45
  temperature=0.7,
46
- convert_system_message_to_human=True #Need this to work well with CrewAI
47
-
48
  )
49
 
 
50
  # 1. Resume Analyzer Agent
51
  resume_analyzer = Agent(
52
  role='Resume Analysis Expert',
53
  goal='Thoroughly analyze the provided resume and identify its strengths and weaknesses.',
54
- backstory="""You are a seasoned resume analyst with years of experience
55
- in helping job seekers optimize their resumes. You are adept at
56
  identifying key skills, experiences, and formatting issues.""",
57
  verbose=True,
58
  allow_delegation=False,
59
- llm=llm
60
  )
61
 
62
  # 2. Job Description Analyzer Agent
63
  job_analyzer = Agent(
64
  role='Job Description Expert',
65
  goal='Analyze the job description and extract key requirements, skills, and keywords.',
66
- backstory="""You are a highly skilled job description analyst.
67
- You excel at identifying the core requirements, desired skills, and
68
  important keywords from any job posting.""",
69
  verbose=True,
70
  allow_delegation=False,
71
- llm=llm
72
  )
73
 
74
  # 3. Resume Improvement Suggestor Agent
75
  improvement_suggestor = Agent(
76
  role='Resume Improvement Specialist',
77
  goal='Provide specific, actionable suggestions to improve the resume based on the job description.',
78
- backstory="""You are a master resume writer and career coach. You
79
- are known for your ability to craft compelling resumes that highlight
80
- a candidate's strengths and align them perfectly with job requirements.
81
  You provide concrete, easy-to-implement suggestions.""",
82
  verbose=True,
83
  allow_delegation=False,
84
- llm=llm
85
  )
86
 
87
  # --- Tasks ---
@@ -103,7 +103,7 @@ def create_crew(job_description, resume_text):
103
  # Task 2: Analyze the Job Description
104
  task_analyze_job_description = Task(
105
  description=f"""Analyze the following job description and extract the key requirements,
106
- desired skills, preferred qualifications, and any important keywords.
107
  Be specific and comprehensive in your analysis. Output a structured summary.
108
  Job Description:
109
  --------------
@@ -122,14 +122,13 @@ def create_crew(job_description, resume_text):
122
  2. **Keywords:** Identify keywords from the job description that should be incorporated into the resume.
123
  3. **Formatting:** Suggest any formatting changes to improve readability and impact.
124
  4. **Overall Strategy:** Provide an overall strategy for tailoring the resume to the specific job.
125
-
126
  The resume analysis is: {task_analyze_resume.output}
127
  The job description analysis is: {task_analyze_job_description.output}
128
  """,
129
  agent=improvement_suggestor,
130
  expected_output="A list of specific, actionable suggestions for improving the resume, covering content, keywords, formatting, and overall strategy, tailored to the job description."
131
  )
132
-
133
  # --- Crew ---
134
  crew = Crew(
135
  agents=[resume_analyzer, job_analyzer, improvement_suggestor],
@@ -162,6 +161,5 @@ if st.button("Tailor Resume"):
162
  st.write(wrap_text(result))
163
  else:
164
  st.error("Failed to read the resume content.")
165
-
166
  else:
167
  st.warning("Please provide both the job description and your resume.")
 
1
  import streamlit as st
2
  from crewai import Agent, Task, Crew, Process
3
+ from langchain_google_genai import ChatGoogleGenerativeAI
4
  import os
5
  import fitz # PyMuPDF for PDF handling
6
  import tempfile
7
  from dotenv import load_dotenv
8
  import textwrap
9
 
10
+ # Load environment variables
11
  load_dotenv()
12
 
13
  # --- Helper Functions ---
 
38
  def create_crew(job_description, resume_text):
39
  """Creates the CrewAI crew with agents and tasks."""
40
 
41
+ # Gemini LLM configuration
42
  llm = ChatGoogleGenerativeAI(
43
  model="gemini-1.5-flash-002", # Specify the Gemini 1.5 Flash model
44
  google_api_key=os.environ.get("GOOGLE_API_KEY"), # Use GOOGLE_API_KEY
45
  temperature=0.7,
46
+ convert_system_message_to_human=True
 
47
  )
48
 
49
+
50
  # 1. Resume Analyzer Agent
51
  resume_analyzer = Agent(
52
  role='Resume Analysis Expert',
53
  goal='Thoroughly analyze the provided resume and identify its strengths and weaknesses.',
54
+ backstory="""You are a seasoned resume analyst with years of experience
55
+ in helping job seekers optimize their resumes. You are adept at
56
  identifying key skills, experiences, and formatting issues.""",
57
  verbose=True,
58
  allow_delegation=False,
59
+ llm=llm # Pass the llm object
60
  )
61
 
62
  # 2. Job Description Analyzer Agent
63
  job_analyzer = Agent(
64
  role='Job Description Expert',
65
  goal='Analyze the job description and extract key requirements, skills, and keywords.',
66
+ backstory="""You are a highly skilled job description analyst.
67
+ You excel at identifying the core requirements, desired skills, and
68
  important keywords from any job posting.""",
69
  verbose=True,
70
  allow_delegation=False,
71
+ llm=llm # Pass the llm object
72
  )
73
 
74
  # 3. Resume Improvement Suggestor Agent
75
  improvement_suggestor = Agent(
76
  role='Resume Improvement Specialist',
77
  goal='Provide specific, actionable suggestions to improve the resume based on the job description.',
78
+ backstory="""You are a master resume writer and career coach. You
79
+ are known for your ability to craft compelling resumes that highlight
80
+ a candidate's strengths and align them perfectly with job requirements.
81
  You provide concrete, easy-to-implement suggestions.""",
82
  verbose=True,
83
  allow_delegation=False,
84
+ llm=llm # Pass the llm object
85
  )
86
 
87
  # --- Tasks ---
 
103
  # Task 2: Analyze the Job Description
104
  task_analyze_job_description = Task(
105
  description=f"""Analyze the following job description and extract the key requirements,
106
+ desired skills, preferred qualifications, and any important keywords.
107
  Be specific and comprehensive in your analysis. Output a structured summary.
108
  Job Description:
109
  --------------
 
122
  2. **Keywords:** Identify keywords from the job description that should be incorporated into the resume.
123
  3. **Formatting:** Suggest any formatting changes to improve readability and impact.
124
  4. **Overall Strategy:** Provide an overall strategy for tailoring the resume to the specific job.
125
+
126
  The resume analysis is: {task_analyze_resume.output}
127
  The job description analysis is: {task_analyze_job_description.output}
128
  """,
129
  agent=improvement_suggestor,
130
  expected_output="A list of specific, actionable suggestions for improving the resume, covering content, keywords, formatting, and overall strategy, tailored to the job description."
131
  )
 
132
  # --- Crew ---
133
  crew = Crew(
134
  agents=[resume_analyzer, job_analyzer, improvement_suggestor],
 
161
  st.write(wrap_text(result))
162
  else:
163
  st.error("Failed to read the resume content.")
 
164
  else:
165
  st.warning("Please provide both the job description and your resume.")