Prathamesh1420 commited on
Commit
b098a37
1 Parent(s): 09cf909

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -51
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  import os
 
3
  import warnings
4
  from crewai import Agent, Task, Crew
5
  from langchain_google_genai import ChatGoogleGenerativeAI
@@ -11,16 +12,23 @@ os.environ['OPENAI_API_KEY'] = 'dummy_key'
11
  # Warning control
12
  warnings.filterwarnings('ignore')
13
 
14
- # Set the Google API key (add your own key)
15
  google_api_key = "AIzaSyCeZHse0Jr8PXBQoKFJg7fZkV_t5w6ViBM"
16
 
17
- # Initialize the Gemini model
18
- llm = ChatGoogleGenerativeAI(
19
- model="gemini-1.5-flash",
20
- verbose=True,
21
- temperature=0.5,
22
- google_api_key=google_api_key
23
- )
 
 
 
 
 
 
 
24
 
25
  # Initialize tools
26
  search_tool = SerperDevTool()
@@ -33,7 +41,12 @@ researcher = Agent(
33
  goal="Make sure to do amazing analysis on job posting to help job applicants",
34
  tools=[scrape_tool, search_tool],
35
  verbose=True,
36
- llm=llm
 
 
 
 
 
37
  )
38
 
39
  profiler = Agent(
@@ -41,7 +54,12 @@ profiler = Agent(
41
  goal="Do incredible research on job applicants to help them stand out in the job market",
42
  tools=[scrape_tool, search_tool, read_resume],
43
  verbose=True,
44
- llm=llm
 
 
 
 
 
45
  )
46
 
47
  resume_strategist = Agent(
@@ -49,7 +67,11 @@ resume_strategist = Agent(
49
  goal="Find all the best ways to make a resume stand out in the job market.",
50
  tools=[scrape_tool, search_tool, read_resume],
51
  verbose=True,
52
- llm=llm
 
 
 
 
53
  )
54
 
55
  interview_preparer = Agent(
@@ -57,7 +79,12 @@ interview_preparer = Agent(
57
  goal="Create interview questions and talking points based on the resume and job requirements",
58
  tools=[scrape_tool, search_tool, read_resume],
59
  verbose=True,
60
- llm=llm
 
 
 
 
 
61
  )
62
 
63
  # Define tasks
@@ -116,48 +143,31 @@ interview_preparation_task = Task(
116
  agent=interview_preparer
117
  )
118
 
119
- # Define Crew
120
  job_application_crew = Crew(
121
  agents=[researcher, profiler, resume_strategist, interview_preparer],
122
  tasks=[research_task, profile_task, resume_strategy_task, interview_preparation_task],
123
  verbose=True
124
  )
125
 
126
- # Streamlit UI
127
- st.title("Job Application Assistant")
128
- st.write("This app helps you tailor your resume and prepare for job interviews.")
129
-
130
- job_posting_url = st.text_input("Job Posting URL")
131
- github_url = st.text_input("GitHub URL")
132
- linkedin_url = st.text_input("LinkedIn URL")
133
- personal_writeup = st.text_area("Personal Write-up", """
134
- Prathamesh Khade is an accomplished Software Engineering Leader with experience in managing teams,
135
- specializing in multiple programming languages and frameworks. He holds a strong background in AI and data science.
136
- Prathamesh has successfully led major tech initiatives, proving his ability to drive innovation and growth in the tech industry.
137
- Ideal for leadership roles that require a strategic and innovative approach.
138
- """)
139
-
140
- if st.button("Submit"):
141
- job_application_inputs = {
142
- 'job_posting_url': job_posting_url,
143
- 'github_url': github_url,
144
- 'linkedin_url': linkedin_url,
145
- 'personal_writeup': personal_writeup
146
- }
147
-
148
- try:
149
- # Kickoff the Crew Execution
150
- result = job_application_crew.kickoff(inputs=job_application_inputs)
151
- st.success("Process completed successfully!")
152
-
153
- # Display results
154
- with open("tailored_resume.md", "r") as f:
155
- st.markdown(f.read())
156
-
157
- with open("interview_materials.md", "r") as f:
158
- st.markdown(f.read())
159
-
160
- except httpx.ConnectError as e:
161
- st.error(f"Connection error occurred: {e}")
162
- except Exception as e:
163
- st.error(f"An error occurred: {e}")
 
1
  import streamlit as st
2
  import os
3
+ import asyncio
4
  import warnings
5
  from crewai import Agent, Task, Crew
6
  from langchain_google_genai import ChatGoogleGenerativeAI
 
12
  # Warning control
13
  warnings.filterwarnings('ignore')
14
 
15
+ # Set the Google API key directly in the code
16
  google_api_key = "AIzaSyCeZHse0Jr8PXBQoKFJg7fZkV_t5w6ViBM"
17
 
18
+ # Function to initialize the Gemini model with an event loop
19
+ async def initialize_llm():
20
+ return ChatGoogleGenerativeAI(
21
+ model="gemini-1.5-flash",
22
+ verbose=True,
23
+ temperature=0.5,
24
+ google_api_key=google_api_key
25
+ )
26
+
27
+ # Run the initialization within the event loop
28
+ if not hasattr(st, 'llm'):
29
+ loop = asyncio.new_event_loop()
30
+ asyncio.set_event_loop(loop)
31
+ st.llm = loop.run_until_complete(initialize_llm())
32
 
33
  # Initialize tools
34
  search_tool = SerperDevTool()
 
41
  goal="Make sure to do amazing analysis on job posting to help job applicants",
42
  tools=[scrape_tool, search_tool],
43
  verbose=True,
44
+ backstory=(
45
+ "As a Job Researcher, your prowess in navigating and extracting critical "
46
+ "information from job postings is unmatched. Your skills help pinpoint the necessary "
47
+ "qualifications and skills sought by employers, forming the foundation for effective application tailoring."
48
+ ),
49
+ llm=st.llm
50
  )
51
 
52
  profiler = Agent(
 
54
  goal="Do incredible research on job applicants to help them stand out in the job market",
55
  tools=[scrape_tool, search_tool, read_resume],
56
  verbose=True,
57
+ backstory=(
58
+ "Equipped with analytical prowess, you dissect and synthesize information "
59
+ "from diverse sources to craft comprehensive personal and professional profiles, laying the "
60
+ "groundwork for personalized resume enhancements."
61
+ ),
62
+ llm=st.llm
63
  )
64
 
65
  resume_strategist = Agent(
 
67
  goal="Find all the best ways to make a resume stand out in the job market.",
68
  tools=[scrape_tool, search_tool, read_resume],
69
  verbose=True,
70
+ backstory=(
71
+ "With a strategic mind and an eye for detail, you excel at refining resumes to highlight the most "
72
+ "relevant skills and experiences, ensuring they resonate perfectly with the job's requirements."
73
+ ),
74
+ llm=st.llm
75
  )
76
 
77
  interview_preparer = Agent(
 
79
  goal="Create interview questions and talking points based on the resume and job requirements",
80
  tools=[scrape_tool, search_tool, read_resume],
81
  verbose=True,
82
+ backstory=(
83
+ "Your role is crucial in anticipating the dynamics of interviews. With your ability to formulate key questions "
84
+ "and talking points, you prepare candidates for success, ensuring they can confidently address all aspects of the "
85
+ "job they are applying for."
86
+ ),
87
+ llm=st.llm
88
  )
89
 
90
  # Define tasks
 
143
  agent=interview_preparer
144
  )
145
 
146
+ # Crew Setup
147
  job_application_crew = Crew(
148
  agents=[researcher, profiler, resume_strategist, interview_preparer],
149
  tasks=[research_task, profile_task, resume_strategy_task, interview_preparation_task],
150
  verbose=True
151
  )
152
 
153
+ # Job Application Inputs
154
+ job_application_inputs = {
155
+ 'job_posting_url': 'https://www.linkedin.com/jobs/search/?alertAction=viewjobs&currentJobId=3971168247&distance=25&f_TPR=a1720706267-&f_WT=1%2C3%2C2&geoId=105524837&keywords=data%20scientist&origin=JOB_ALERT_IN_APP_NOTIFICATION&originToLandingJobPostings=3971106469&savedSearchId=1741028074&sortBy=R',
156
+ 'github_url': 'https://github.com/Pk-Kolhapurkar',
157
+ 'linkedin_url': 'https://www.linkedin.com/in/prathamesh-khade-434615217/',
158
+ 'personal_writeup': """
159
+ Prathamesh Khade is an accomplished Software Engineering Leader with experience in managing teams,
160
+ specializing in multiple programming languages and frameworks. He holds a strong background in AI and data science.
161
+ Prathamesh has successfully led major tech initiatives, proving his ability to drive innovation and growth in the tech industry.
162
+ Ideal for leadership roles that require a strategic and innovative approach."""
163
+ }
164
+
165
+ # Kickoff the Crew Execution
166
+ result = job_application_crew.kickoff(inputs=job_application_inputs)
167
+
168
+ # Display results
169
+ st.markdown("# Tailored Resume")
170
+ st.markdown(open("tailored_resume.md").read())
171
+
172
+ st.markdown("# Interview Materials")
173
+ st.markdown(open("interview_materials.md").read())