Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
@@ -33,6 +35,39 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
@@ -46,8 +81,6 @@ model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may
|
|
| 46 |
custom_role_conversions=None,
|
| 47 |
)
|
| 48 |
|
| 49 |
-
duckduck_tool = DuckDuckGoSearchTool()
|
| 50 |
-
|
| 51 |
# Import tool from Hub
|
| 52 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 53 |
|
|
@@ -56,7 +89,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 56 |
|
| 57 |
agent = CodeAgent(
|
| 58 |
model=model,
|
| 59 |
-
tools=[duckduck_tool, final_answer], ## add your tools here (don't remove final answer)
|
| 60 |
max_steps=6,
|
| 61 |
verbosity_level=1,
|
| 62 |
grammar=None,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from jobspy import scrape_jobs
|
| 8 |
+
import pandas as pd
|
| 9 |
|
| 10 |
from Gradio_UI import GradioUI
|
| 11 |
|
|
|
|
| 35 |
except Exception as e:
|
| 36 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 37 |
|
| 38 |
+
@tool
|
| 39 |
+
def fetch_jobs(search_term: str, location: str, results: int) -> str:
|
| 40 |
+
"""A tool that fetches recent job postings from job boards using JobSpy.
|
| 41 |
+
|
| 42 |
+
Args:
|
| 43 |
+
search_term: The job title or keywords to search for (e.g., 'data scientist').
|
| 44 |
+
location: The geographic location to filter jobs by (e.g., 'New York, NY' or 'Remote').
|
| 45 |
+
results: The number of job postings to retrieve (e.g., 10 or 20).
|
| 46 |
+
|
| 47 |
+
Returns:
|
| 48 |
+
A string containing a formatted list of job titles, companies, locations, and links.
|
| 49 |
+
Each job is shown on its own line.
|
| 50 |
+
"""
|
| 51 |
+
jobs = scrape_jobs(
|
| 52 |
+
site_name=["indeed", "linkedin", "zip_recruiter", "glassdoor", "google", "bayt", "naukri"],
|
| 53 |
+
search_term=search_term,
|
| 54 |
+
location=location,
|
| 55 |
+
results_wanted=results,
|
| 56 |
+
hours_old=72,
|
| 57 |
+
country_indeed='USA',
|
| 58 |
+
# linkedin_fetch_description=True # gets more info such as description, direct job url (slower)
|
| 59 |
+
# proxies=["208.195.175.46:65095", "208.195.175.45:65095", "localhost"],
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
# Prepare a human-readable response
|
| 63 |
+
jobs_subset = jobs[["title", "company", "location", "job_url"]]
|
| 64 |
+
lines = [
|
| 65 |
+
f"{row.title} at {row.company} ({row.location})\n{row.job_url}"
|
| 66 |
+
for _, row in jobs_subset.iterrows()
|
| 67 |
+
]
|
| 68 |
+
return "\n\n".join(lines) if lines else "No jobs found for the given criteria."
|
| 69 |
+
|
| 70 |
+
duckduck_tool = DuckDuckGoSearchTool()
|
| 71 |
|
| 72 |
final_answer = FinalAnswerTool()
|
| 73 |
|
|
|
|
| 81 |
custom_role_conversions=None,
|
| 82 |
)
|
| 83 |
|
|
|
|
|
|
|
| 84 |
# Import tool from Hub
|
| 85 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 86 |
|
|
|
|
| 89 |
|
| 90 |
agent = CodeAgent(
|
| 91 |
model=model,
|
| 92 |
+
tools=[duckduck_tool, fetch_jobs, final_answer], ## add your tools here (don't remove final answer)
|
| 93 |
max_steps=6,
|
| 94 |
verbosity_level=1,
|
| 95 |
grammar=None,
|