Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,6 +29,27 @@ def get_nbp_exchange_rate(currency: str) -> float:
|
|
| 29 |
else:
|
| 30 |
raise ValueError(f"Failed to fetch exchange rate for {currency}. HTTP Status: {response.status_code}")
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 33 |
@tool
|
| 34 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
@@ -78,7 +99,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 78 |
|
| 79 |
agent = CodeAgent(
|
| 80 |
model=model,
|
| 81 |
-
tools=[get_nbp_exchange_rate, get_current_time_in_timezone, image_generation_tool, final_answer], ## add your tools here (don't remove final answer)
|
| 82 |
max_steps=6,
|
| 83 |
verbosity_level=1,
|
| 84 |
grammar=None,
|
|
|
|
| 29 |
else:
|
| 30 |
raise ValueError(f"Failed to fetch exchange rate for {currency}. HTTP Status: {response.status_code}")
|
| 31 |
|
| 32 |
+
|
| 33 |
+
@tool
|
| 34 |
+
def get_billboard_hot_100_last_countdown() -> list:
|
| 35 |
+
"""A tool that fetches the latest Billboard Hot 100 countdown.
|
| 36 |
+
|
| 37 |
+
Returns:
|
| 38 |
+
A list of the top 10 songs from the latest Billboard Hot 100.
|
| 39 |
+
"""
|
| 40 |
+
import requests
|
| 41 |
+
from bs4 import BeautifulSoup
|
| 42 |
+
|
| 43 |
+
url = "https://www.billboard.com/charts/hot-100/"
|
| 44 |
+
response = requests.get(url)
|
| 45 |
+
|
| 46 |
+
if response.status_code == 200:
|
| 47 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
| 48 |
+
songs = soup.select(".o-chart-results-list__item h3")
|
| 49 |
+
return [song.get_text(strip=True) for song in songs[:10]]
|
| 50 |
+
else:
|
| 51 |
+
raise ValueError(f"Failed to fetch Billboard Hot 100. HTTP Status: {response.status_code}")
|
| 52 |
+
|
| 53 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 54 |
@tool
|
| 55 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 99 |
|
| 100 |
agent = CodeAgent(
|
| 101 |
model=model,
|
| 102 |
+
tools=[get_nbp_exchange_rate, get_billboard_hot_100_last_countdown, get_current_time_in_timezone, image_generation_tool, final_answer], ## add your tools here (don't remove final answer)
|
| 103 |
max_steps=6,
|
| 104 |
verbosity_level=1,
|
| 105 |
grammar=None,
|