preslaff commited on
Commit
722be32
·
unverified ·
1 Parent(s): ee06ab0

Fixed, now is output_type = 'list[string]'

Browse files
Files changed (1) hide show
  1. 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 Dict, List
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 = "dict" # ✅ Use "dict" instead of "list[dict]"
16
 
17
- def forward(self, position: str, location: str, work_mode: str) -> Dict:
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
- "title": job["title"],
41
- "company": job.get("company_name", "N/A"),
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 {"jobs": formatted_jobs} # ✅ Wrap list inside a dictionary
50
 
51
  else:
52
- return {"error": f"Error {response.status_code}: {response.text}"}
 
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