Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,6 @@ from Gradio_UI import GradioUI
|
|
11 |
final_answer = FinalAnswerTool()
|
12 |
visit_webpage = VisitWebpageTool()
|
13 |
web_search = DuckDuckGoSearchTool()
|
14 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
15 |
|
16 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
17 |
@tool
|
@@ -24,6 +23,27 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
24 |
"""
|
25 |
return "What magic will you build ?"
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
@tool
|
28 |
def get_current_time_in_timezone(timezone: str) -> str:
|
29 |
"""A tool that fetches the current local time in a specified timezone.
|
|
|
11 |
final_answer = FinalAnswerTool()
|
12 |
visit_webpage = VisitWebpageTool()
|
13 |
web_search = DuckDuckGoSearchTool()
|
|
|
14 |
|
15 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
16 |
@tool
|
|
|
23 |
"""
|
24 |
return "What magic will you build ?"
|
25 |
|
26 |
+
@tool
|
27 |
+
def get_crypto_price(crypto: str, currency: str) -> str:
|
28 |
+
"""A tool to fetch real-time cryptocurrency prices from CoinGecko API.
|
29 |
+
|
30 |
+
Args:
|
31 |
+
crypto: The cryptocurrency symbol (e.g., 'bitcoin', 'ethereum').
|
32 |
+
currency: The fiat currency (e.g., 'usd', 'twd').
|
33 |
+
|
34 |
+
Returns:
|
35 |
+
The current price of the cryptocurrency in the specified currency.
|
36 |
+
"""
|
37 |
+
url = f"https://api.coingecko.com/api/v3/simple/price?ids={crypto}&vs_currencies={currency}"
|
38 |
+
try:
|
39 |
+
response = requests.get(url)
|
40 |
+
response.raise_for_status()
|
41 |
+
data = response.json()
|
42 |
+
price = data.get(crypto, {}).get(currency, "N/A")
|
43 |
+
return f"The current price of {crypto} in {currency} is {price}"
|
44 |
+
except requests.RequestException as e:
|
45 |
+
return f"Error fetching price: {e}"
|
46 |
+
|
47 |
@tool
|
48 |
def get_current_time_in_timezone(timezone: str) -> str:
|
49 |
"""A tool that fetches the current local time in a specified timezone.
|