Fixed, now is output_type = 'list[string]'
Browse files- tools/linkedin_job_search.py +8 -12
tools/linkedin_job_search.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
from smolagents.tools import Tool
|
2 |
import requests
|
3 |
-
from typing import
|
4 |
|
5 |
class LinkedInJobSearchTool(Tool):
|
6 |
name = "linkedin_job_search"
|
@@ -12,9 +12,9 @@ class LinkedInJobSearchTool(Tool):
|
|
12 |
"work_mode": {"type": "string", "description": "remote, hybrid, in-office"}
|
13 |
}
|
14 |
|
15 |
-
output_type = "
|
16 |
|
17 |
-
def forward(self, position: str, location: str, work_mode: str) ->
|
18 |
"""
|
19 |
Searches LinkedIn for job postings using SerpAPI.
|
20 |
"""
|
@@ -36,17 +36,13 @@ class LinkedInJobSearchTool(Tool):
|
|
36 |
job_results = data.get("jobs_results", [])
|
37 |
|
38 |
formatted_jobs = [
|
39 |
-
{
|
40 |
-
|
41 |
-
|
42 |
-
"location": job.get("location", "N/A"),
|
43 |
-
"posted_date": job.get("detected_extensions", {}).get("posted_at", "N/A"),
|
44 |
-
"link": job.get("job_id", "N/A")
|
45 |
-
}
|
46 |
for job in job_results
|
47 |
]
|
48 |
|
49 |
-
return
|
50 |
|
51 |
else:
|
52 |
-
return
|
|
|
1 |
from smolagents.tools import Tool
|
2 |
import requests
|
3 |
+
from typing import List
|
4 |
|
5 |
class LinkedInJobSearchTool(Tool):
|
6 |
name = "linkedin_job_search"
|
|
|
12 |
"work_mode": {"type": "string", "description": "remote, hybrid, in-office"}
|
13 |
}
|
14 |
|
15 |
+
output_type = "list[string]" # ✅ Compatible with smolagents and Gradio list output
|
16 |
|
17 |
+
def forward(self, position: str, location: str, work_mode: str) -> List[str]:
|
18 |
"""
|
19 |
Searches LinkedIn for job postings using SerpAPI.
|
20 |
"""
|
|
|
36 |
job_results = data.get("jobs_results", [])
|
37 |
|
38 |
formatted_jobs = [
|
39 |
+
f"Title: {job['title']}, Company: {job.get('company_name', 'N/A')}, "
|
40 |
+
f"Location: {job.get('location', 'N/A')}, Posted: {job.get('detected_extensions', {}).get('posted_at', 'N/A')}, "
|
41 |
+
f"Link: {job.get('job_id', 'N/A')}"
|
|
|
|
|
|
|
|
|
42 |
for job in job_results
|
43 |
]
|
44 |
|
45 |
+
return formatted_jobs # ✅ Returns a list of formatted job strings for Gradio
|
46 |
|
47 |
else:
|
48 |
+
return [f"Error: {response.status_code} - {response.text}"] # Error as a list
|