Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
|
2 |
import datetime
|
3 |
import requests
|
4 |
import pytz
|
|
|
5 |
import yaml
|
6 |
from tools.final_answer import FinalAnswerTool
|
7 |
|
@@ -33,6 +34,23 @@ 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 |
|
@@ -55,7 +73,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[final_answer, get_current_time_in_timezone, image_generation_tool], ## add your tools here (don't remove final answer)
|
59 |
max_steps=6,
|
60 |
verbosity_level=3,
|
61 |
grammar=None,
|
|
|
2 |
import datetime
|
3 |
import requests
|
4 |
import pytz
|
5 |
+
import os
|
6 |
import yaml
|
7 |
from tools.final_answer import FinalAnswerTool
|
8 |
|
|
|
34 |
except Exception as e:
|
35 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
36 |
|
37 |
+
@tool
|
38 |
+
def find_job(city:str, keyword:int)-> str: #it's import to specify the return type
|
39 |
+
"""A tool that yields top 10 vacancies in the given US city with given keywords in title
|
40 |
+
Args:
|
41 |
+
city: the US city
|
42 |
+
keyword: keywords in the job title to search for
|
43 |
+
"""
|
44 |
+
host = 'jooble.org'
|
45 |
+
key = os.environ.get('JOOBLE_KEY')
|
46 |
+
|
47 |
+
url = f'https://{host}/api/{key}'
|
48 |
+
headers = {"Content-type": "application/json"}
|
49 |
+
body = '{ "keywords": ' + keyword + ', "location": ' + city + '}'
|
50 |
+
|
51 |
+
response = requests.post(url, data=body, headers=headers)
|
52 |
+
return response.json()['jobs'][0:10]
|
53 |
+
|
54 |
|
55 |
final_answer = FinalAnswerTool()
|
56 |
|
|
|
73 |
|
74 |
agent = CodeAgent(
|
75 |
model=model,
|
76 |
+
tools=[final_answer, get_current_time_in_timezone, image_generation_tool, find_job], ## add your tools here (don't remove final answer)
|
77 |
max_steps=6,
|
78 |
verbosity_level=3,
|
79 |
grammar=None,
|