OppaAI commited on
Commit
e9525f9
·
verified ·
1 Parent(s): 90365b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -30
app.py CHANGED
@@ -8,34 +8,19 @@ logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(
8
  logger = logging.getLogger(__name__)
9
  mcp = FastMCP("Jobicy Remote Jobs Agent")
10
 
11
- # 🧩 官方选项
12
- JOB_CATEGORIES = ["", "Business & Management", "Content & Editorial", "Customer Service",
13
- "Creative & Design", "DevOps & SysAdmin", "Software Engineering",
14
- "Finance & Accounting", "HR & Recruiting", "Product & Operations",
15
- "Programming", "Sales & Marketing"]
16
-
17
- JOB_TYPES = ["", "Remote Full Time Jobs", "Remote Part Time Jobs", "Remote Contract Jobs"]
18
-
19
- COMPANY_INDUSTRIES = ["", "Technology", "Finance & Accounting", "Health, Wellness & Fitness",
20
- "Internet & Online Media"]
21
-
22
  COUNTRY_CHOICES = ["Anywhere", "usa", "canada", "uk", "europe", "latam", "apac"]
23
 
24
-
25
  @mcp.tool(name="search_jobs")
26
- def search_jobs_tool(category: str = "",
27
- job_type: str = "",
28
- industry: str = "",
29
- country: str = "",
30
- limit: int = 20) -> dict:
31
  """
32
  Search remote jobs via Jobicy API, supports filters.
33
 
34
  Args:
35
- category (str): A Jobicy job category.
36
- job_type (str): One of Job Types.
37
  industry (str): Company industry filter.
38
  country (str): Region filter (e.g., usa, canada, ...).
 
39
  limit (int): Number of results (1–50).
40
 
41
  Returns:
@@ -43,14 +28,12 @@ def search_jobs_tool(category: str = "",
43
  """
44
  base = "https://jobicy.com/api/v2/remote-jobs"
45
  params = {"count": max(1, min(limit, 50))}
46
- if category:
47
- params["industry"] = category.lower().replace(" & ", "-").replace(" ", "-")
48
- if job_type:
49
- params["jobType"] = job_type.lower().replace(" ", "-")
50
  if industry:
51
  params["companyIndustry"] = industry.lower().replace(" & ", "-").replace(" ", "-")
52
  if country and country.lower() != "anywhere":
53
  params["geo"] = country.lower()
 
 
54
 
55
  logger.info(f"Requesting Jobicy API with params: {params}")
56
  try:
@@ -78,9 +61,8 @@ def search_jobs_tool(category: str = "",
78
  sorted_jobs = sorted(jobs_raw, key=lambda x: x.get("pubDate", ""), reverse=True)[:params["count"]]
79
  return {"jobs": [fmt(j) for j in sorted_jobs]}
80
 
81
-
82
- def search_jobs_ui(category, job_type, industry, country, limit):
83
- res = search_jobs_tool(category, job_type, industry, country, limit)
84
  if "error" in res:
85
  return f"❌ {res['error']}"
86
  if not res["jobs"]:
@@ -98,19 +80,17 @@ def search_jobs_ui(category, job_type, industry, country, limit):
98
  )
99
  return md
100
 
101
-
102
  app = gr.Interface(
103
  fn=search_jobs_ui,
104
  inputs=[
105
- gr.Dropdown(label="Job Category (optional)", choices=JOB_CATEGORIES, value=""),
106
- gr.Dropdown(label="Job Type (optional)", choices=JOB_TYPES, value=""),
107
  gr.Dropdown(label="Company Industry (optional)", choices=COMPANY_INDUSTRIES, value=""),
108
  gr.Dropdown(label="Country / Region (optional)", choices=COUNTRY_CHOICES, value="Anywhere"),
 
109
  gr.Slider(minimum=1, maximum=50, value=20, step=1, label="Number of Results"),
110
  ],
111
  outputs=gr.Markdown(),
112
  title="Jobicy Remote Job Search",
113
- description="Filter remote jobs by category, type, industry, and region (as per Jobicy official options), results sorted by recent postings.",
114
  theme="huggingface"
115
  )
116
 
 
8
  logger = logging.getLogger(__name__)
9
  mcp = FastMCP("Jobicy Remote Jobs Agent")
10
 
11
+ # Remaining filter options
12
+ COMPANY_INDUSTRIES = ["", "Technology", "Finance & Accounting", "Health, Wellness & Fitness", "Internet & Online Media"]
 
 
 
 
 
 
 
 
 
13
  COUNTRY_CHOICES = ["Anywhere", "usa", "canada", "uk", "europe", "latam", "apac"]
14
 
 
15
  @mcp.tool(name="search_jobs")
16
+ def search_jobs_tool(industry: str = "", country: str = "", keyword: str = "", limit: int = 20) -> dict:
 
 
 
 
17
  """
18
  Search remote jobs via Jobicy API, supports filters.
19
 
20
  Args:
 
 
21
  industry (str): Company industry filter.
22
  country (str): Region filter (e.g., usa, canada, ...).
23
+ keyword (str): Free-form keyword tag.
24
  limit (int): Number of results (1–50).
25
 
26
  Returns:
 
28
  """
29
  base = "https://jobicy.com/api/v2/remote-jobs"
30
  params = {"count": max(1, min(limit, 50))}
 
 
 
 
31
  if industry:
32
  params["companyIndustry"] = industry.lower().replace(" & ", "-").replace(" ", "-")
33
  if country and country.lower() != "anywhere":
34
  params["geo"] = country.lower()
35
+ if keyword:
36
+ params["search"] = keyword.strip()
37
 
38
  logger.info(f"Requesting Jobicy API with params: {params}")
39
  try:
 
61
  sorted_jobs = sorted(jobs_raw, key=lambda x: x.get("pubDate", ""), reverse=True)[:params["count"]]
62
  return {"jobs": [fmt(j) for j in sorted_jobs]}
63
 
64
+ def search_jobs_ui(industry, country, keyword, limit):
65
+ res = search_jobs_tool(industry=industry, country=country, keyword=keyword, limit=limit)
 
66
  if "error" in res:
67
  return f"❌ {res['error']}"
68
  if not res["jobs"]:
 
80
  )
81
  return md
82
 
 
83
  app = gr.Interface(
84
  fn=search_jobs_ui,
85
  inputs=[
 
 
86
  gr.Dropdown(label="Company Industry (optional)", choices=COMPANY_INDUSTRIES, value=""),
87
  gr.Dropdown(label="Country / Region (optional)", choices=COUNTRY_CHOICES, value="Anywhere"),
88
+ gr.Textbox(label="Keyword / Tag (optional)", placeholder="e.g., python, data, UX"),
89
  gr.Slider(minimum=1, maximum=50, value=20, step=1, label="Number of Results"),
90
  ],
91
  outputs=gr.Markdown(),
92
  title="Jobicy Remote Job Search",
93
+ description="Search remote jobs by industry, region, and keyword. Results sorted by most recent.",
94
  theme="huggingface"
95
  )
96