Fixed assertion error for input list, now gives list(dict)
Browse files
tools/linkedin_job_search.py
CHANGED
@@ -5,18 +5,20 @@ from typing import Dict, List
|
|
5 |
class LinkedInJobSearchTool(Tool):
|
6 |
name = "linkedin_job_search"
|
7 |
description = "Searches for jobs on LinkedIn based on job title, location, and work mode (remote, hybrid, in-office)."
|
|
|
8 |
inputs = {
|
9 |
-
"position": {"type": "string", "description": "Job title
|
10 |
-
"location": {"type": "string", "description": "City or country
|
11 |
-
"work_mode": {"type": "string", "description": "
|
12 |
}
|
13 |
-
|
|
|
14 |
|
15 |
def forward(self, position: str, location: str, work_mode: str) -> List[Dict]:
|
16 |
"""
|
17 |
Searches LinkedIn for job postings using SerpAPI.
|
18 |
"""
|
19 |
-
SERPAPI_KEY = "2f660e5a696e7d1d08662085b95f83a61224476ec19558de3c68218baf346e43" # Replace with your
|
20 |
base_url = "https://serpapi.com/search"
|
21 |
|
22 |
params = {
|
@@ -33,8 +35,7 @@ class LinkedInJobSearchTool(Tool):
|
|
33 |
data = response.json()
|
34 |
job_results = data.get("jobs_results", [])
|
35 |
|
36 |
-
|
37 |
-
formatted_jobs = [
|
38 |
{
|
39 |
"title": job["title"],
|
40 |
"company": job.get("company_name", "N/A"),
|
@@ -44,7 +45,5 @@ class LinkedInJobSearchTool(Tool):
|
|
44 |
}
|
45 |
for job in job_results
|
46 |
]
|
47 |
-
|
48 |
-
return formatted_jobs
|
49 |
else:
|
50 |
return [{"error": f"Error {response.status_code}: {response.text}"}]
|
|
|
5 |
class LinkedInJobSearchTool(Tool):
|
6 |
name = "linkedin_job_search"
|
7 |
description = "Searches for jobs on LinkedIn based on job title, location, and work mode (remote, hybrid, in-office)."
|
8 |
+
|
9 |
inputs = {
|
10 |
+
"position": {"type": "string", "description": "Job title (e.g., Data Scientist)"},
|
11 |
+
"location": {"type": "string", "description": "City or country (e.g., New York)"},
|
12 |
+
"work_mode": {"type": "string", "description": "remote, hybrid, in-office"}
|
13 |
}
|
14 |
+
|
15 |
+
output_type = "list[dict]" # ✅ Use an authorized output type
|
16 |
|
17 |
def forward(self, position: str, location: str, work_mode: str) -> List[Dict]:
|
18 |
"""
|
19 |
Searches LinkedIn for job postings using SerpAPI.
|
20 |
"""
|
21 |
+
SERPAPI_KEY = "2f660e5a696e7d1d08662085b95f83a61224476ec19558de3c68218baf346e43" # Replace with your API key
|
22 |
base_url = "https://serpapi.com/search"
|
23 |
|
24 |
params = {
|
|
|
35 |
data = response.json()
|
36 |
job_results = data.get("jobs_results", [])
|
37 |
|
38 |
+
return [
|
|
|
39 |
{
|
40 |
"title": job["title"],
|
41 |
"company": job.get("company_name", "N/A"),
|
|
|
45 |
}
|
46 |
for job in job_results
|
47 |
]
|
|
|
|
|
48 |
else:
|
49 |
return [{"error": f"Error {response.status_code}: {response.text}"}]
|