ArchiMathur commited on
Commit
bf42fe0
·
verified ·
1 Parent(s): 5b302d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -76
app.py CHANGED
@@ -1,7 +1,3 @@
1
-
2
-
3
-
4
-
5
  import gradio as gr
6
  import pandas as pd
7
  import numpy as np
@@ -17,7 +13,7 @@ data = pd.read_csv("mldata.csv")
17
  # Function to load model based on selection
18
  def load_model(model_choice):
19
  if model_choice == "Random Forest":
20
- with open('rfweights (1).pkl', 'rb') as pickleFile:
21
  return pickle.load(pickleFile)
22
  elif model_choice == "Decision Tree":
23
  with open('dtreeweights.pkl', 'rb') as pickleFile:
@@ -54,80 +50,41 @@ career_interest_references = create_embedding_dict('interested career area ')
54
  company_intends_references = create_embedding_dict('Type of company want to settle in?')
55
  book_interest_references = create_embedding_dict('Interested Type of Books')
56
 
57
- # # Function to fetch job listings
58
- # def fetch_job_listings(job_title):
59
- # url = "https://jobs-api14.p.rapidapi.com/v2/list"
60
- # querystring = {
61
- # "query": "software engineer",
62
- # "location": "India",
63
- # "autoTranslateLocation": "false",
64
- # "remoteOnly": "false",
65
- # "employmentTypes": "fulltime;parttime;intern;contractor"
66
- # }
67
- # headers = {
68
- # "x-rapidapi-key": "47d14c1b58msh66e23d95e91b8bep110e5fjsn64ef19ff56c0",
69
- # "x-rapidapi-host": "job-posting-feed-api.p.rapidapi.com"
70
- # }
71
-
72
- # try:
73
- # response = requests.get(url, headers=headers, params=querystring)
74
- # job_data = response.json()
75
-
76
- # # Process and format job listings
77
- # if job_data.get('jobs'):
78
- # job_listings = []
79
- # for job in job_data['jobs'][:5]: # Limit to 5 job listings
80
- # job_listings.append([
81
- # job.get('title', 'N/A'),
82
- # job.get('company', 'N/A'),
83
- # job.get('location', 'N/A'),
84
- # job.get('salary', 'Not specified')
85
- # ])
86
- # return job_listings
87
- # else:
88
- # return [['No job listings', 'found', 'for this', 'career path']]
89
-
90
- # except requests.RequestException as e:
91
- # return [['Error', 'fetching', 'job listings', str(e)]]
92
-
93
-
94
-
95
- import requests
96
-
97
  def fetch_job_listings(job_title):
98
- url = "https://active-jobs-db.p.rapidapi.com/active-ats-7d"
99
-
100
- params = {
101
- "limit": "10",
102
- "title_filter": job_title,
103
- "location_filter": "United States",
104
- "description_type": "text"
105
  }
106
-
107
  headers = {
108
- "X-RapidAPI-Key": "47d14c1b58msh66e23d95e91b8bep110e5fjsn64ef19ff56c0",
109
- "X-RapidAPI-Host": "active-jobs-db.p.rapidapi.com"
110
  }
111
 
112
- response = requests.get(url, headers=headers, params=params)
113
- job_data = response.json()
114
-
115
- print("RAW RESPONSE:", job_data)
116
-
117
- # ✅ Active Jobs DB returns a LIST, not dict
118
- if isinstance(job_data, list) and len(job_data) > 0:
119
- jobs = []
120
- for job in job_data[:5]:
121
- jobs.append([
122
- job.get("title", "N/A"),
123
- job.get("organization", "N/A"),
124
- job.get("location", "N/A"),
125
- job.get("salary_raw", "Not specified")
126
- ])
127
- return jobs
128
- else:
129
- return [["No job listings", "found", "for this", "career path"]]
130
-
 
131
 
132
  # Prediction function (modified to return job suggestions)
133
  def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_skills, public_speaking_skills,
@@ -277,8 +234,7 @@ demo = gr.Interface(
277
  gr.Dropdown(worker_list, label="Are you a Smart worker or Hard worker?")
278
  ],
279
  outputs=create_output_component(),
280
- title="AI-Enhanced Career guidance System",
281
-
282
  )
283
 
284
  # Main execution
 
 
 
 
 
1
  import gradio as gr
2
  import pandas as pd
3
  import numpy as np
 
13
  # Function to load model based on selection
14
  def load_model(model_choice):
15
  if model_choice == "Random Forest":
16
+ with open('rfweights.pkl', 'rb') as pickleFile:
17
  return pickle.load(pickleFile)
18
  elif model_choice == "Decision Tree":
19
  with open('dtreeweights.pkl', 'rb') as pickleFile:
 
50
  company_intends_references = create_embedding_dict('Type of company want to settle in?')
51
  book_interest_references = create_embedding_dict('Interested Type of Books')
52
 
53
+ # Function to fetch job listings
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  def fetch_job_listings(job_title):
55
+ url = "https://jobs-api14.p.rapidapi.com/v2/list"
56
+ querystring = {
57
+ "query": job_title,
58
+ "location": "India",
59
+ "autoTranslateLocation": "false",
60
+ "remoteOnly": "false",
61
+ "employmentTypes": "fulltime;parttime;intern;contractor"
62
  }
 
63
  headers = {
64
+ "x-rapidapi-key": "47d14c1b58msh66e23d95e91b8bep110e5fjsn64ef19ff56c0",
65
+ "x-rapidapi-host": "jobs-api14.p.rapidapi.com"
66
  }
67
 
68
+ try:
69
+ response = requests.get(url, headers=headers, params=querystring)
70
+ job_data = response.json()
71
+
72
+ # Process and format job listings
73
+ if job_data.get('jobs'):
74
+ job_listings = []
75
+ for job in job_data['jobs'][:5]: # Limit to 5 job listings
76
+ job_listings.append([
77
+ job.get('title', 'N/A'),
78
+ job.get('company', 'N/A'),
79
+ job.get('location', 'N/A'),
80
+ job.get('salary', 'Not specified')
81
+ ])
82
+ return job_listings
83
+ else:
84
+ return [['No job listings', 'found', 'for this', 'career path']]
85
+
86
+ except requests.RequestException as e:
87
+ return [['Error', 'fetching', 'job listings', str(e)]]
88
 
89
  # Prediction function (modified to return job suggestions)
90
  def rfprediction(model_choice, name, logical_thinking, hackathon_attend, coding_skills, public_speaking_skills,
 
234
  gr.Dropdown(worker_list, label="Are you a Smart worker or Hard worker?")
235
  ],
236
  outputs=create_output_component(),
237
+ title="Ai-Enhanced career guidance system"
 
238
  )
239
 
240
  # Main execution