Added job_search_tool tool in tools
Browse files- .ipynb_checkpoints/agent-checkpoint.json +2 -1
- .ipynb_checkpoints/app-checkpoint.py +4 -2
- agent.json +2 -1
- app.py +4 -2
- tools/linkedin_job_search.py +50 -0
.ipynb_checkpoints/agent-checkpoint.json
CHANGED
|
@@ -2,7 +2,8 @@
|
|
| 2 |
"tools": [
|
| 3 |
"web_search",
|
| 4 |
"visit_webpage",
|
| 5 |
-
"final_answer"
|
|
|
|
| 6 |
],
|
| 7 |
"model": {
|
| 8 |
"class": "HfApiModel",
|
|
|
|
| 2 |
"tools": [
|
| 3 |
"web_search",
|
| 4 |
"visit_webpage",
|
| 5 |
+
"final_answer",
|
| 6 |
+
"job_search_tool"
|
| 7 |
],
|
| 8 |
"model": {
|
| 9 |
"class": "HfApiModel",
|
.ipynb_checkpoints/app-checkpoint.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -6,6 +6,7 @@ import yaml
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
from tools.visit_webpage import VisitWebpageTool
|
| 8 |
from tools.web_search import DuckDuckGoSearchTool
|
|
|
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
|
@@ -39,6 +40,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 39 |
final_answer = FinalAnswerTool()
|
| 40 |
visit_webpage = VisitWebpageTool()
|
| 41 |
web_search = DuckDuckGoSearchTool()
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
@@ -60,7 +62,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 60 |
|
| 61 |
agent = CodeAgent(
|
| 62 |
model=model,
|
| 63 |
-
tools=[final_answer, visit_webpage, web_search, image_generation_tool, get_current_time_in_timezone],## add your tools here (don't remove final answer)
|
| 64 |
max_steps=6,
|
| 65 |
verbosity_level=1,
|
| 66 |
grammar=None,
|
|
|
|
| 1 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool, Agent
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
from tools.visit_webpage import VisitWebpageTool
|
| 8 |
from tools.web_search import DuckDuckGoSearchTool
|
| 9 |
+
from tools.linkedin_job_search import LinkedInJobSearchTool
|
| 10 |
|
| 11 |
from Gradio_UI import GradioUI
|
| 12 |
|
|
|
|
| 40 |
final_answer = FinalAnswerTool()
|
| 41 |
visit_webpage = VisitWebpageTool()
|
| 42 |
web_search = DuckDuckGoSearchTool()
|
| 43 |
+
job_search_tool = LinkedInJobSearchTool()
|
| 44 |
|
| 45 |
|
| 46 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
|
| 62 |
|
| 63 |
agent = CodeAgent(
|
| 64 |
model=model,
|
| 65 |
+
tools=[final_answer, visit_webpage, web_search, image_generation_tool, get_current_time_in_timezone, job_search_tool],## add your tools here (don't remove final answer)
|
| 66 |
max_steps=6,
|
| 67 |
verbosity_level=1,
|
| 68 |
grammar=None,
|
agent.json
CHANGED
|
@@ -2,7 +2,8 @@
|
|
| 2 |
"tools": [
|
| 3 |
"web_search",
|
| 4 |
"visit_webpage",
|
| 5 |
-
"final_answer"
|
|
|
|
| 6 |
],
|
| 7 |
"model": {
|
| 8 |
"class": "HfApiModel",
|
|
|
|
| 2 |
"tools": [
|
| 3 |
"web_search",
|
| 4 |
"visit_webpage",
|
| 5 |
+
"final_answer",
|
| 6 |
+
"job_search_tool"
|
| 7 |
],
|
| 8 |
"model": {
|
| 9 |
"class": "HfApiModel",
|
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -6,6 +6,7 @@ import yaml
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
from tools.visit_webpage import VisitWebpageTool
|
| 8 |
from tools.web_search import DuckDuckGoSearchTool
|
|
|
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
|
@@ -39,6 +40,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 39 |
final_answer = FinalAnswerTool()
|
| 40 |
visit_webpage = VisitWebpageTool()
|
| 41 |
web_search = DuckDuckGoSearchTool()
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
@@ -60,7 +62,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 60 |
|
| 61 |
agent = CodeAgent(
|
| 62 |
model=model,
|
| 63 |
-
tools=[final_answer, visit_webpage, web_search, image_generation_tool, get_current_time_in_timezone],## add your tools here (don't remove final answer)
|
| 64 |
max_steps=6,
|
| 65 |
verbosity_level=1,
|
| 66 |
grammar=None,
|
|
|
|
| 1 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool, Agent
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
from tools.visit_webpage import VisitWebpageTool
|
| 8 |
from tools.web_search import DuckDuckGoSearchTool
|
| 9 |
+
from tools.linkedin_job_search import LinkedInJobSearchTool
|
| 10 |
|
| 11 |
from Gradio_UI import GradioUI
|
| 12 |
|
|
|
|
| 40 |
final_answer = FinalAnswerTool()
|
| 41 |
visit_webpage = VisitWebpageTool()
|
| 42 |
web_search = DuckDuckGoSearchTool()
|
| 43 |
+
job_search_tool = LinkedInJobSearchTool()
|
| 44 |
|
| 45 |
|
| 46 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
|
| 62 |
|
| 63 |
agent = CodeAgent(
|
| 64 |
model=model,
|
| 65 |
+
tools=[final_answer, visit_webpage, web_search, image_generation_tool, get_current_time_in_timezone, job_search_tool],## add your tools here (don't remove final answer)
|
| 66 |
max_steps=6,
|
| 67 |
verbosity_level=1,
|
| 68 |
grammar=None,
|
tools/linkedin_job_search.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"
|
| 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 or keyword (e.g., Data Scientist)"},
|
| 10 |
+
"location": {"type": "string", "description": "City or country where the job is located (e.g., New York, Remote)"},
|
| 11 |
+
"work_mode": {"type": "string", "description": "Preferred work setting: remote, hybrid, in-office"}
|
| 12 |
+
}
|
| 13 |
+
output_type = "list" # Returning a list of job postings
|
| 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 SerpAPI key
|
| 20 |
+
base_url = "https://serpapi.com/search"
|
| 21 |
+
|
| 22 |
+
params = {
|
| 23 |
+
"engine": "google_jobs",
|
| 24 |
+
"q": f"{position} {work_mode} jobs",
|
| 25 |
+
"location": location,
|
| 26 |
+
"hl": "en",
|
| 27 |
+
"api_key": SERPAPI_KEY
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
response = requests.get(base_url, params=params)
|
| 31 |
+
|
| 32 |
+
if response.status_code == 200:
|
| 33 |
+
data = response.json()
|
| 34 |
+
job_results = data.get("jobs_results", [])
|
| 35 |
+
|
| 36 |
+
# Extracting relevant job info
|
| 37 |
+
formatted_jobs = [
|
| 38 |
+
{
|
| 39 |
+
"title": job["title"],
|
| 40 |
+
"company": job.get("company_name", "N/A"),
|
| 41 |
+
"location": job.get("location", "N/A"),
|
| 42 |
+
"posted_date": job.get("detected_extensions", {}).get("posted_at", "N/A"),
|
| 43 |
+
"link": job.get("job_id", "N/A")
|
| 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}"}]
|