OppaAI commited on
Commit
e827b81
·
verified ·
1 Parent(s): 7634afd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -1,11 +1,11 @@
1
  import gradio as gr
2
- import requests
3
  from fastmcp import FastMCP
4
 
5
  mcp = FastMCP("Indeed Job Search Agent")
6
 
7
  @mcp.tool(name="search_jobs")
8
- def search_jobs_tool(query: str, location: str, date_created: str = None, salary: str = None, job_type: str = None):
9
  url = "https://employers.indeed.com/api/v2/jobs"
10
  params = {
11
  "q": query,
@@ -19,18 +19,18 @@ def search_jobs_tool(query: str, location: str, date_created: str = None, salary
19
  "statuses": "ACTIVE",
20
  "fields": "title,id,company,location,url"
21
  }
22
- # Remove parameters with None values
23
  params = {k: v for k, v in params.items() if v is not None}
24
 
25
- try:
26
- response = requests.get(url, params=params)
27
- response.raise_for_status()
28
- return response.json()
29
- except requests.RequestException as e:
30
- return {"error": str(e)}
 
31
 
32
- def search_jobs_ui(query, location, date_created=None, salary=None, job_type=None):
33
- result = mcp.run("search_jobs", inputs={
34
  "query": query,
35
  "location": location,
36
  "date_created": date_created,
 
1
  import gradio as gr
2
+ import httpx
3
  from fastmcp import FastMCP
4
 
5
  mcp = FastMCP("Indeed Job Search Agent")
6
 
7
  @mcp.tool(name="search_jobs")
8
+ async def search_jobs_tool(query: str, location: str, date_created: str = None, salary: str = None, job_type: str = None):
9
  url = "https://employers.indeed.com/api/v2/jobs"
10
  params = {
11
  "q": query,
 
19
  "statuses": "ACTIVE",
20
  "fields": "title,id,company,location,url"
21
  }
 
22
  params = {k: v for k, v in params.items() if v is not None}
23
 
24
+ async with httpx.AsyncClient() as client:
25
+ try:
26
+ response = await client.get(url, params=params)
27
+ response.raise_for_status()
28
+ return response.json()
29
+ except httpx.RequestError as e:
30
+ return {"error": str(e)}
31
 
32
+ async def search_jobs_ui(query, location, date_created=None, salary=None, job_type=None):
33
+ result = await mcp.run("search_jobs", inputs={
34
  "query": query,
35
  "location": location,
36
  "date_created": date_created,