Prathamesh1420 commited on
Commit
af4cf37
1 Parent(s): f4c439d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -39
app.py CHANGED
@@ -4,13 +4,16 @@ import asyncio
4
  import warnings
5
  from crewai import Agent, Task, Crew
6
  from langchain_google_genai import ChatGoogleGenerativeAI
7
- from crewai_tools import FileReadTool, ScrapeWebsiteTool, MDXSearchTool, SerperDevTool
 
 
 
8
 
9
  # Warning control
10
  warnings.filterwarnings('ignore')
11
 
12
  # Set the Google API key directly in the code
13
- google_api_key = "AIzaSyCHHl4LgpZIBw3_Zf15XWuuLSWWIlLROdQ"
14
 
15
  # Function to initialize the Gemini model with an event loop
16
  async def initialize_llm():
@@ -27,39 +30,10 @@ if not hasattr(st, 'llm'):
27
  asyncio.set_event_loop(loop)
28
  st.llm = loop.run_until_complete(initialize_llm())
29
 
30
- # Ensure the SERPER API key is correctly passed during initialization
31
- serper_api_key = "42e088db08191f8f2f7d516a9016f579306b5d6d3940d86d840d5370207a5b6c" # Replace with your actual API key
32
- search_tool = SerperDevTool(api_key=serper_api_key)
33
-
34
  # Initialize tools
 
35
  scrape_tool = ScrapeWebsiteTool()
36
-
37
- # Initialize read_resume
38
- read_resume = FileReadTool(file_path='fake_resume.md')
39
-
40
- # Initialize semantic_search_resume with error handling
41
- semantic_search_resume = None
42
- try:
43
- semantic_search_resume = MDXSearchTool(
44
- config=dict(
45
- llm=dict(
46
- provider="ollama",
47
- config=dict(
48
- model="llama2",
49
- ),
50
- ),
51
- embedder=dict(
52
- provider="google",
53
- config=dict(
54
- model="models/embedding-001",
55
- task_type="retrieval_document",
56
- ),
57
- ),
58
- ),
59
- mdx='fake_resume.md'
60
- )
61
- except Exception as e:
62
- st.error(f"Failed to initialize MDXSearchTool: {e}")
63
 
64
  # Define agents
65
  researcher = Agent(
@@ -78,7 +52,7 @@ researcher = Agent(
78
  profiler = Agent(
79
  role="Personal Profiler for Engineers",
80
  goal="Do incredible research on job applicants to help them stand out in the job market",
81
- tools=[scrape_tool, search_tool, read_resume, semantic_search_resume] if semantic_search_resume else [scrape_tool, search_tool, read_resume],
82
  verbose=True,
83
  backstory=(
84
  "Equipped with analytical prowess, you dissect and synthesize information "
@@ -91,7 +65,7 @@ profiler = Agent(
91
  resume_strategist = Agent(
92
  role="Resume Strategist for Engineers",
93
  goal="Find all the best ways to make a resume stand out in the job market.",
94
- tools=[scrape_tool, search_tool, read_resume, semantic_search_resume] if semantic_search_resume else [scrape_tool, search_tool, read_resume],
95
  verbose=True,
96
  backstory=(
97
  "With a strategic mind and an eye for detail, you excel at refining resumes to highlight the most "
@@ -103,7 +77,7 @@ resume_strategist = Agent(
103
  interview_preparer = Agent(
104
  role="Engineering Interview Preparer",
105
  goal="Create interview questions and talking points based on the resume and job requirements",
106
- tools=[scrape_tool, search_tool, read_resume, semantic_search_resume] if semantic_search_resume else [scrape_tool, search_tool, read_resume],
107
  verbose=True,
108
  backstory=(
109
  "Your role is crucial in anticipating the dynamics of interviews. With your ability to formulate key questions "
@@ -178,14 +152,14 @@ job_application_crew = Crew(
178
 
179
  # Job Application Inputs
180
  job_application_inputs = {
181
- 'job_posting_url': 'https://jobs.lever.co/AIFund/6c82e23e-d954-4dd8-a734-c0c2c5ee00f1?lever-origin=applied&lever-source%5B%5D=AI+Fund',
182
  'github_url': 'https://github.com/PrathameshK',
183
  'linkedin_url': 'https://www.linkedin.com/in/prathameshkhade/',
184
- 'personal_writeup': 'fake_resume.md'
185
  }
186
 
187
  # Running Tasks
188
- results = job_application_crew.kickoff(inputs=job_application_inputs)
189
 
190
  # Display Results
191
  st.write(results)
 
4
  import warnings
5
  from crewai import Agent, Task, Crew
6
  from langchain_google_genai import ChatGoogleGenerativeAI
7
+ from crewai_tools import FileReadTool, ScrapeWebsiteTool, SerperDevTool
8
+
9
+ # Set a dummy key to prevent KeyError
10
+ os.environ['OPENAI_API_KEY'] = 'dummy_key'
11
 
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():
 
30
  asyncio.set_event_loop(loop)
31
  st.llm = loop.run_until_complete(initialize_llm())
32
 
 
 
 
 
33
  # Initialize tools
34
+ search_tool = SerperDevTool()
35
  scrape_tool = ScrapeWebsiteTool()
36
+ read_resume = FileReadTool(file_path='./content/fake_resume.md')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  # Define agents
39
  researcher = Agent(
 
52
  profiler = Agent(
53
  role="Personal Profiler for Engineers",
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 "
 
65
  resume_strategist = Agent(
66
  role="Resume Strategist for Engineers",
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 "
 
77
  interview_preparer = Agent(
78
  role="Engineering Interview Preparer",
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 "
 
152
 
153
  # Job Application Inputs
154
  job_application_inputs = {
155
+ 'job_posting_url': 'https://www.linkedin.com/jobs/collections/recommended/?currentJobId=3971777873&eBP=CwEAAAGQrDjDbzY9VTxQvSF6zCLu0cNQm7McJPCymw_4YJ8KCIVPoQei_6I17FtkEl3pSY6WlAKOhS8fRwXHDF_xfH_JEO-gDqRBLJxgqKKft7TD6vMZusTgtuTByPjJcH6zhNVaUF9wssog8T3wU8gdHVraMmgTdanjeQTJcRy0CP6ynYmlo1mw_XPetqaclf8h5vamDp-M0z-Y5BwEaHiVCSUNf2mfJ7VyAnsInisr2wGPmC0YhFdQzsgRTkdFGFMoejs-xM_lYDnc_22gM5pV4mHXGetgnDxK6Oot_Ip3PHd6jjKJbvcRoLDxK5640RvxV4EkNEUU7cPtw0FcWbg74hvggF1VJquPVNAhNjZpLxh8Hbe94JsEvWQyGiuTSHpG2v0STF8SvT6g3sy04uZwxF7B5dQIAyEcqbrT6hFhpEeWvUtVW30e_Ezehz8T7hLWUV2p_uXW6ZQCKjyPqVwQkre26YtDqQSi38X722bq1qD5Y0wV0cms&refId=TV8NgrFTQZQm7k6gZko9FQ%3D%3D&trackingId=j%2FkIgFHDTmriZJHR%2BxOhOA%3D%3D',
156
  'github_url': 'https://github.com/PrathameshK',
157
  'linkedin_url': 'https://www.linkedin.com/in/prathameshkhade/',
158
+ 'personal_writeup': './content/fake_resume.md'
159
  }
160
 
161
  # Running Tasks
162
+ results = job_application_crew.run_tasks(inputs=job_application_inputs)
163
 
164
  # Display Results
165
  st.write(results)