VPCSinfo commited on
Commit
fbd16a2
·
1 Parent(s): 12c5e3d

[ADD][FIX] Odoo specific job profile search with linkedin job search. added brave api search engine.

Browse files
.gitignore CHANGED
@@ -1 +1,18 @@
1
- .ipynb_checkpoints/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ipynb_checkpoints/
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ .env
6
+ venv/
7
+ __pycache__/
8
+ *.pyc
9
+ *.pyo
10
+ *$py.class
11
+ *~
12
+ *.swp
13
+ *.log
14
+ /instance
15
+ # Byte-compiled / optimized / DLL files
16
+ __pycache__/
17
+ *.py[cod]
18
+ *$py.class
requirements.txt CHANGED
@@ -3,3 +3,5 @@ smolagents
3
  requests
4
  duckduckgo_search
5
  pandas
 
 
 
3
  requests
4
  duckduckgo_search
5
  pandas
6
+ smolagents[gradio]
7
+ python-dotenv
tools/__pycache__/final_answer.cpython-311.pyc DELETED
Binary file (2.5 kB)
 
tools/__pycache__/linkedin_job_search.cpython-311.pyc DELETED
Binary file (3.16 kB)
 
tools/__pycache__/visit_webpage.cpython-311.pyc DELETED
Binary file (2.88 kB)
 
tools/__pycache__/web_search.cpython-311.pyc DELETED
Binary file (2.66 kB)
 
tools/linkedin_job_search.py CHANGED
@@ -1,10 +1,14 @@
1
  from smolagents.tools import Tool
2
  import requests
3
  from typing import List, Dict
 
 
 
 
4
 
5
  class LinkedInJobSearchTool(Tool):
6
  name = "linkedin_job_search"
7
- description = "Searches for job postings 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)"},
@@ -16,17 +20,17 @@ class LinkedInJobSearchTool(Tool):
16
 
17
  def forward(self, position: str, location: str, work_mode: str) -> List[Dict]:
18
  """
19
- Fetches job listings from LinkedIn using SerpAPI and returns structured JSON.
20
  """
21
- SERPAPI_KEY = "YOUR-API-KEY" # Replace with actual key
22
- base_url = "https://serpapi.com/search"
 
 
23
 
24
  params = {
25
- "engine": "google_jobs",
26
- "q": f"{position} {work_mode} jobs",
27
  "location": location,
28
- "hl": "en",
29
- "api_key": SERPAPI_KEY
30
  }
31
 
32
  try:
@@ -34,19 +38,21 @@ class LinkedInJobSearchTool(Tool):
34
  response.raise_for_status()
35
 
36
  data = response.json()
37
- job_results = data.get("jobs_results", [])
38
 
39
  # ✅ Properly format job URLs
40
- return [
41
- {
42
- "Title": job["title"],
43
- "Company": job.get("company_name", "N/A"),
44
- "Location": job.get("location", "N/A"),
45
- "Posted": job.get("detected_extensions", {}).get("posted_at", "N/A"),
46
- "Link": f"https://www.linkedin.com/jobs/view/{job['job_id']}" if "job_id" in job else "N/A"
47
- }
48
- for job in job_results
49
- ] if job_results else [{"Error": "No jobs found. Try different keywords."}]
 
 
50
 
51
  except requests.exceptions.RequestException as e:
52
  return [{"Error": f"Error fetching job listings: {str(e)}"}]
 
1
  from smolagents.tools import Tool
2
  import requests
3
  from typing import List, Dict
4
+ import os
5
+ from dotenv import load_dotenv
6
+
7
+ load_dotenv()
8
 
9
  class LinkedInJobSearchTool(Tool):
10
  name = "linkedin_job_search"
11
+ description = "Searches for job postings on LinkedIn based on job title, location, and work mode (remote, hybrid, in-office) for Odoo profiles."
12
 
13
  inputs = {
14
  "position": {"type": "string", "description": "Job title (e.g., Data Scientist)"},
 
20
 
21
  def forward(self, position: str, location: str, work_mode: str) -> List[Dict]:
22
  """
23
+ Fetches job listings from LinkedIn using Brave API and returns structured JSON.
24
  """
25
+ BRAVE_API_KEY = os.getenv("BRAVE_API_KEY")
26
+ if not BRAVE_API_KEY:
27
+ return [{"Error": "Brave API key not found in .env file."}]
28
+ base_url = "https://api.brave.com/v1/jobs"
29
 
30
  params = {
31
+ "q": f"Odoo {position} {work_mode} jobs",
 
32
  "location": location,
33
+ "api_key": BRAVE_API_KEY
 
34
  }
35
 
36
  try:
 
38
  response.raise_for_status()
39
 
40
  data = response.json()
41
+ job_results = data.get("jobs", [])
42
 
43
  # ✅ Properly format job URLs
44
+ formatted_results = ""
45
+ if job_results:
46
+ for job in job_results:
47
+ formatted_results += f"Title: {job['title']}\n"
48
+ formatted_results += f"Company: {job.get('company', 'N/A')}\n"
49
+ formatted_results += f"Location: {job.get('location', 'N/A')}\n"
50
+ formatted_results += f"Posted: {job.get('posted_date', 'N/A')}\n"
51
+ formatted_results += f"Link: {job.get('url', 'N/A')}\n"
52
+ formatted_results += "---\n"
53
+ else:
54
+ formatted_results = "No jobs found. Try different keywords."
55
+ return [{"Results": formatted_results}]
56
 
57
  except requests.exceptions.RequestException as e:
58
  return [{"Error": f"Error fetching job listings: {str(e)}"}]